Ho un problema con NSOperation
e osservatore.Errore NSOpertura, osservatore e thread
Ho un tabbarcontroller
e un splashController
. Voglio caricare lo splashscreen e scaricare il file e quando il file è scaricato fai apparire sullo schermo il tabbarcontroller
.
Il problema è che 'ho un errore:
bool _WebTryThreadLock (bool), 0x3d2fa90: cercato di ottenere bloccare il web da un thread diverso dal thread principale o il filo web. Questo può essere un risultato di chiamare a UIKit da un thread secondario. Crashing ora ...
Questo è il mio codice:
- (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");
}
Qualcuno mi potrebbe aiutare?