Tengo un problema con NSOperation
y observador.NSOperation, observer and thread error
Tengo tabbarcontroller
y splashController
. Quiero que la pantalla secundaria se cargue y descargue el archivo, y cuando se descargue el archivo, haga que aparezca tabbarcontroller
en la pantalla.
El problema es que he un error:
_WebTryThreadLock bool (bool), 0x3d2fa90: tratado de obtener bloquear la web de un hilo distinto del hilo principal o el hilo web. Esto puede ser el resultado de llamar a UIKit desde un hilo secundario. Estrellarse ahora ...
Este es mi 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");
}
Podría alguien ayudarme?