NSOperation, observador e erro de thread
Eu tenho um problema comNSOperation
e observador.
Eu tenho umtabbarcontroller
e umsplashController
. Eu quero a carga splashscreen e baixar o arquivo e quando o arquivo é baixado fazer otabbarcontroller
aparecem na tela.
O problema é que eu tenho um erro:
bool _WebTryThreadLock (bool), 0x3d2fa90: Tentou obter o bloqueio da web de um encadeamento diferente do encadeamento principal ou do encadeamento da web. Isso pode ser um resultado de chamar o UIKit de um thread secundário. Batendo agora ...
Este é o meu código:
- (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");
}
Alguém pode ajudar-me ?