I have a function that sometimes takes too long to run. I want to attempt to run it for 10 seconds, and then just kill it if it's not done. How do I do this in Objective C on the iPhone?
Creating the persistent store coordinator is failing for some users who have a lot of data in their database, because the object model merging takes too long. We've moved that data storage out of the database, but I want to kill the model merging if it takes more than a set time limit, and delete the database file so that the users can continue to use the app.
NSPersistentStoreCoordinator* psc = [[[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel: [self managedObjectModelForDatabase:dbName]] autorelease];