Skip to content

Instantly share code, notes, and snippets.

@quique123
Created November 27, 2009 17:47
Show Gist options
  • Save quique123/244142 to your computer and use it in GitHub Desktop.
Save quique123/244142 to your computer and use it in GitHub Desktop.
-(void)synchronousLoadTwitterData{
// Beause this is ran inside a seprate thread we have to be real careful
// that the data we play with here doesn't clobber another thread that is
// running at the exact same time. We will build a temprary array that we
// will assign the instance variable to only on the main thread.
// setup the tweet array and log it ONCE
publicTweets = [[NSMutableArray alloc]init];
// this needs to be a new operation so as not to block the main thread...
NSArray *userTimeline = [[NSArray alloc] initWithArray:[TwitterHelper fetchPublicTimeline]];
for ( int i = 0 ; i< [userTimeline count]; i++) {
[publicTweets addObject:[[userTimeline objectAtIndex:i] objectForKey:@"text" ]];
NSLog(@"Tweets %@ DFLTDWR", publicTweets);
NSLog(@"==============>Timeline Array at index %d Status Msg:%@", i, [[userTimeline objectAtIndex: i] objectForKey:@"text" ]);
}
[self performSelectorOnMainThread:@selector(didFinishLoadingTwitterDataWithResults:) withObject:publicTweets waitUntilDone:NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment