Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Core data Swift-向核心数据添加支持iCloud的持久存储_Core Data_Swift_Store_Icloud_Persistent - Fatal编程技术网

Core data Swift-向核心数据添加支持iCloud的持久存储

Core data Swift-向核心数据添加支持iCloud的持久存储,core-data,swift,store,icloud,persistent,Core Data,Swift,Store,Icloud,Persistent,这给我带来了一个错误: var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) let documentsDirectory:NSURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL let storeUrl:N

这给我带来了一个错误:

var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
let documentsDirectory:NSURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let storeUrl:NSURL = documentsDirectory.URLByAppendingPathComponent("CoreData.sqlite")
var error:NSError?
let coordinator:NSPersistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: appDel.managedObjectModel)
let storeOptions:NSDictionary = [NSPersistentStoreUbiquitousContentNameKey:"MyAppCloudStore"]
let store:NSPersistentStore = coordinator.addPersistentStoreWithType("NSSQLiteStoreType", configuration: nil, URL: storeUrl, options: storeOptions, error: &error)!
let finaliCloudURL = store.URL

我已经启用了iCloud的服务功能:键值存储是一个定义的常量值。您需要使用
NSSQLiteStoreType
,而不是
@NSSQLiteStoreType”
。虽然
NSSQLiteStoreType
是一个字符串,但它的值不是
@“NSSQLiteStoreType”
让store:NSPersistentStore=coordinator.addPersistentStoreWithType(NSSQLiteStoreType,配置:nil,URL:storeUrl,选项:storeOptions,错误:&错误)!
2014-12-18 13:55:59.160 TestApp[1410:314557] CoreData: error: -addPersistentStoreWithType:NSSQLiteStoreType configuration:(null) URL:file:///Users/Bogdan-iMac/Library/Developer/CoreSimulator/Devices/29BD765A-1F4A-4C8A-8EAE-4AA0B1E91918/data/Containers/Data/Application/F19B3C5D-B6AD-4944-B4F3-BBBE4AF36D66/Documents/CoreData.sqlite options:{
    NSPersistentStoreUbiquitousContentNameKey = MyAppCloudStore;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134080 "The NSSQLiteStoreType persistent store type does not support iCloud integration." UserInfo=0x79fc9360 {NSLocalizedDescription=The NSSQLiteStoreType persistent store type does not support iCloud integration.} with userInfo dictionary {
    NSLocalizedDescription = "The NSSQLiteStoreType persistent store type does not support iCloud integration.";
}
fatal error: unexpectedly found nil while unwrapping an Optional value