Я пытаюсь отобразить UIActivityIndicatorView во время фоновой обработки.
Приведенный ниже упрощенный код работает, когда я пробую его в симуляторе (отображается предупреждение) ... но когда я загружаю его на свой телефон из XCode, фоновый поток, кажется, вообще не вызывается. (предупреждение никогда не отображается)
Есть идеи?
-(void)viewDidLoad {
[self performSelectorInBackground:@selector(runInAnotherThread) withObject:nil];
}
-(void) runInAnotherThread {
NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ];
int i;
for(i=0;i < 1000 ;i ++){
NSLog(@"INDEX = %d", i);
}
[self performSelectorOnMainThread : @ selector(backToMainThread ) withObject:nil waitUntilDone:NO];
[ pool release ];
}
-(void) backToMainThread {
UIAlertView *completeAlert = [[UIAlertView alloc]
initWithTitle:@"Back to main "
message: @"Success"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[completeAlert show];
[completeAlert release];
}