I am working on Instagram integration in IOS.Every thing goes well.I am geting the feeds of the user and displaying them on tableview and also in scroll view.Here the user is allowed to refresh the page.While refreshing the method is not getting called and its getting crashed because of zero objects in array.I had used the following code to call the method.
-(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];
}
}
The called method was like this
- (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******//
}
I am calling the above request method again while refreshing
- (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];
}
Please tell me where I am going wrong.Correction appreciated.Thanks in advance.
Try it....
[NSTimer scheduledTimerWithTimeInterval:0.5f
target:self
selector:@selector(showTime)
userInfo:NULL
repeats:YES];
- (void)showTime
{
NSLog(@"Method called");
}
Use NSTimer for call method frequently.
Hope i helped.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.