【发布时间】:2013-05-02 05:27:09
【问题描述】:
我正在 IOS 中进行 Instagram 集成。一切顺利。我正在获取用户的提要并在 tableview 和滚动视图中显示它们。这里允许用户刷新页面。同时刷新方法没有被调用并且由于数组中的零个对象而崩溃。我使用以下代码调用该方法。
-(IBAction)loginAction:(id)sender
{
AppDelegate* appDelegate_new = (AppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate_new.instagram authorize:[NSArray arrayWithObjects:@"comments", @"likes", nil]];
if ([appDelegate.instagram isSessionValid]) {
// NSLog(@"ViewDidLoad Session Valid");
loginView.hidden=YES;
crossButton.hidden=YES;
settingsButton.hidden=NO;
noticeView.hidden=YES;
[self.view addSubview:feedsView];
// [self.logOutView removeFromSuperview];
self.feedsView.frame=CGRectMake(0, 0, 240, 300);
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
[appDelegate.instagram requestWithParams:params
delegate:self];
}
}
调用的方法是这样的
- (void)request:(IGRequest *)request didLoad:(id)result
{
[self performSelector:@selector(startspinner) withObject:nil afterDelay:0.1];
self.data = (NSMutableArray *)[result objectForKey:@"data"];
// NSLog(@"Data Count is %@",[self.data description]);
createdArray=[[NSMutableArray alloc]init];
//*****Here I am performing Json Parsing******//
}
我在刷新时再次调用上述请求方法
- (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl
{
[createdArray removeAllObjects];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
[appDelegate.instagram requestWithParams:params
delegate:self];
[self performSelector:@selector(refreshData) withObject:nil afterDelay:5.0];
}
请告诉我哪里出错了。感谢指正。在此先感谢。
【问题讨论】:
-
你每次调用哪个方法?
-
@jack :检查我的答案。
-
@Sunny 抱歉回复晚了..正在开会...我正在打电话 - “(void)request:(IGRequest *)request didLoad:(id)result” 每次..
-
你为什么要调用 requestDidLoad 呢?当请求最终完成时,请求不应该调用它吗?您在何时何地发生崩溃?
-
它在表格视图中......如果数组计数为零,那么它就会崩溃。这是因为我正在解析请求方法本身的数据。但是它没有被称为@HermannKlecker
标签: iphone ios objective-c ipad instagram