我遇到了問題NSOperation
和觀察者。NSOperation,觀察者和線程錯誤
我有一個tabbarcontroller
和splashController
。我想要加載splashscreen並下載文件,並且下載文件時,屏幕上會顯示tabbarcontroller
。
的問題是,我已經錯誤:
布爾_WebTryThreadLock(布爾),0x3d2fa90:嘗試以獲得將紙幅從比主線程或web線程以外的線程鎖定 。這可能是 是從輔助線程調用UIKit的結果。轟然 現在......
這是我的代碼:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
queue = [[NSOperationQueue alloc] init];
NSString *path = [NSString stringWithFormat:@"%@flux.xml",DOCPATH];
//Le fichier existe dans le repertoire des documents
if([[NSFileManager defaultManager] fileExistsAtPath:path])
[window addSubview:tabBarController.view];
else
{
splash = [[SplashController alloc] init];
[window addSubview:splash.view];
}
DataLoadOperation *operation = [[DataLoadOperation alloc] initWithURL:[NSURL URLWithString:@"http://sly.33.free.fr/flux.xml"]];
[self.queue addOperation:operation];
[operation addObserver:self forKeyPath:@"isFinished" options:NSKeyValueObservingOptionNew context:nil];
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
NSLog(@"fini");
}
誰能幫助我?