Reputation: 16664
I need to wait until file is moved to a new location to use it.
In simulator this code runs fast and file is moved to a new location before I start using it, but on real device it's not.
I tried to use @synchronized
but seems it's not the right tool.
Any advices?
NSURL *newurl = [[legacyPersistentStoreURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"guide"];
NSURL *desturl = [newurl URLByAppendingPathComponent:@"StoreContent"];
[[NSFileManager defaultManager] createDirectoryAtURL:desturl withIntermediateDirectories:YES attributes:nil error:NULL];
NSURL *finalurl = [desturl URLByAppendingPathComponent:@"persistentStore"];
[fileManager moveItemAtURL:legacyPersistentStoreURL toURL:finalurl error:NULL];
Upvotes: 2
Views: 1810
Reputation: 10251
This method may help
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;
Upvotes: 2