得到它的工作。我创建了辅助方法来获取 Caches 文件夹路径作为 NSString
- (NSString *)applicationCachesDirectoryString
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
BOOL isDir = NO;
NSError *error;
if (! [[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&isDir] && isDir == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
}
return cachePath;
}
然后将其传递给 objectStore init 方法:
self.objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:databaseName inDirectory:[self applicationCachesDirectoryString] usingSeedDatabaseName:seedDatabaseName managedObjectModel:managedObjectModel delegate:self];