NSOperation, observador y error de hilo
Tengo un problema conNSOperation
y observador.
Tengo unatabbarcontroller
y unsplashController
. Quiero que la pantalla de bienvenida cargue y descargue el archivo y, cuando se descargue, haga quetabbarcontroller
Aparecerá en la pantalla.
El problema es que tengo un error:
bool _WebTryThreadLock (bool), 0x3d2fa90: se intentó obtener el bloqueo web de un subproceso que no sea el hilo principal o el hilo web. Esto puede ser el resultado de llamar a UIKit desde un hilo secundario. Chocando 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?