How to hold for a moment in program?
I am fetching data from f开发者_如何学编程acebook and during the time of fetching the data, it is taking few milliseconds or a second. I want to be on hold untill fetched data perfectly.
How to write code for this?
- (void)viewDidLoad
{
[self performSelectorInBackground:@selector(startFatching) withObject:nil];
[super viewDidLoad];
}
- (void) startFatching
{
[self performSelectorOnMainThread:@selector(startIndicator) withObject:nil waitUntilDone:NO];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// your code
[self performSelectorOnMainThread:@selector(stopIndicator) withObject:nil waitUntilDone:NO];
[pool release];
}
- (void) startIndicator
{
av.hidesWhenStopped = YES;
[av startAnimating];
}
- (void) stoprIndicator
{
[av stopAnimating];
}
hope this will give you some idea
精彩评论