我有一个使用 ODRefreshControl 的 tableView。当视图加载一切正常时,数据被加载到 tableview 中。但是当我使用 ODRefreshControl 重新加载 tableview 时,它会崩溃。
这就是我正在做的事情:
-(void)fetchFeed:(NSString *)profile_id andAuthToken:(NSString *)authToken andRefresh:(ODRefreshControl *)refreshControl{
posts = [[NSMutableArray alloc]init];
posts2 = [[NSMutableArray alloc]init];
NSLog(@"here");
NSString *urlString = [NSString stringWithFormat:@"https://graph.facebook.com/%@/feed?%@",profile_id,authToken];
NSString* escapedUrlString =[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:escapedUrlString];
NSURLRequest *request;
request = [NSURLRequest requestWithURL:url];
NSLog(@"here2");
AFJSONRequestOperation * __unsafe_unretained operation;
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
NSLog(@"here4");
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"here3");
_nextUrl = [JSON valueForKeyPath:@"paging.next"];
posts = [[JSON objectForKey:@"data"]mutableCopy ];
for (int i=0;i<posts.count;i++){
NSDictionary *post = [posts objectAtIndex:i];
if(([[post valueForKeyPath:@"from.id"]isEqualToString:@"161595817205146"])&& (!([post valueForKey:@"message"] == NULL))){
[posts2 addObject:post];
}
}
NSLog(@"posts are %@",posts2);
[MBProgressHUD hideHUDForView:self.view animated:YES];
[refreshControl endRefreshing];
[self.tableView reloadData];
} failure:^( NSURLRequest *request ,NSHTTPURLResponse *response ,NSError *error , id JSON ){
NSLog(@"error is %@",error);
}];
[operation start];
}
如您所见,我使用 AFJSONRequestOperation。我已将其设置为 *unsafe_unretained。因为我在想我遇到了同样的问题。 但是应用程序仍然崩溃。当你看我的日志时。
2013-05-29 08:59:16.237 genkonstage[6892:907] here
2013-05-29 08:59:16.238 genkonstage[6892:907] here2
2013-05-29 08:59:16.238 genkonstage[6892:907] here4
2013-05-29 08:59:16.242 genkonstage[6892:907] T restkit.network:RKObjectRequestOperation.m:172 GET 'https://graph.facebook.com/161595817205146/feed?access_token=467641956646156%7Cel1qACWFQsCG8fLyh4W81aoIZqw':
request.headers=(null)
request.body=(null)
2013-05-29 08:59:16.387 genkonstage[6892:907] *** Terminating app due to uncaught exception of class '_NSZombie_NSException'
libc++abi.dylib: terminate called throwing an exception
有人可以帮我吗?