J'ai un problème avec NSOperation
et observateur. J'ai un tabbarcontroller
et un splashController
. Je veux charger le splashscreen et télécharger le fichier et quand le fichier est téléchargé faire le tabbarcontroller
apparaître à l'écran.NSOpération, observateur et erreur de fil
Le problème est que j'ai une erreur:
bool _WebTryThreadLock (bool), 0x3d2fa90: a essayé d'obtenir le verrouillage web à partir d'un fil autre que le fil conducteur ou le fil de la nappe. Cela peut être le résultat d'un appel à UIKit à partir d'un thread secondaire. Crashing maintenant ...
Voici mon code:
- (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");
}
Quelqu'un pourrait-il me aider?