我在coreData应用程序中为我的 – (NSPersistentStoreCoordinator *)persistentStoreCoordinator编写了这段代码.我使用xCode的Master-Detail Application模板来创建应用程序……
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (__persistentStoreCoordinator != nil) { return __persistentStoreCoordinator; } NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Notes2.sqlite"]; NSError *error = nil; __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![__persistentStoreCoordinator addPersistentStoreWithType:NSsqliteStoreType configuration:nil URL:storeURL options:nil error:&error]) { NSLog(@"Unresolved error %@,%@",error,[error userInfo]); abort(); } NSString *urlString = [storeURL absoluteString]; NSDictionary *fileAttributes = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; if (![[NSFileManager defaultManager] setAttributes:fileAttributes ofItemAtPath:urlString error:&error]) { // Handle error } return __persistentStoreCoordinator; }
如何测试并知道我的sqlite已打开NSFileProtectionComplete?