在iOS 10中返回nil的NSPersistentStoreCoordinator的SkypeForBusiness.framework addPersistentStoreWithType方法

时间:2016-10-25 11:25:12

标签: ios objective-c ipad skype-for-business

我正在为我的应用程序使用SkypeForBusiness.framework,现在在将我的ipad 4更新为iOS 10后,当我在带有iOS 9.3的ipad 3上运行相同的代码时,NSPersistentStoreCoordinator的addPersistentStoreWithType方法返回 nil 。 5它返回一个对象

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {

static NSPersistentStoreCoordinator *coordinator = nil;
static dispatch_once_t token;
dispatch_once(&token, ^{

    // get the model
    NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:nil];

    // get the coordinator
    coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];

    // add store
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *applicationSupportURL = [[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
    [fileManager createDirectoryAtURL:applicationSupportURL withIntermediateDirectories:NO attributes:nil error:nil];
    NSURL *databaseURL = [applicationSupportURL URLByAppendingPathComponent:@"database_name.sqlite"];
    NSError *error = nil;

    //        [[NSFileManager defaultManager] removeItemAtURL:databaseURL error:&error];

    NSDictionary *options = @{
                              EncryptedStorePassphraseKey : @"********",
                              //            EncryptedStoreDatabaseLocation : databaseURL,
                              NSMigratePersistentStoresAutomaticallyOption : @YES,
                              NSInferMappingModelAutomaticallyOption : @YES
                              };
    NSPersistentStore *store = [coordinator
                                addPersistentStoreWithType:EncryptedStoreType
                                configuration:nil
                                URL:databaseURL
                                options:options
                                error:&error];
    //        coordinator = [EncryptedStore makeStoreWithOptions:options managedObjectModel:model];

    NSAssert(store, @"Unable to add persistent store!\n%@", error);

});
return coordinator;

}

1 个答案:

答案 0 :(得分:0)

我终于找到了解决问题的方法

以前的Xcode就像xcode 6& 7用来抛出这样的错误

  

“_ sqlite3_key”未找到架构i386的符号

现在在Xcode 8中

  

***断言失败 - [AppDelegate persistentStoreCoordinator],/ Usrs /prosares /Desktop / MyProject / MyApp / AppDelegate.m:198

     

***由于未捕获的异常终止应用程序' NSInternalInconsistencyException',原因:'无法添加持久存储!   (空)'

Xcode 8抛出无关的错误,@ Apple应该解决这种类型的错误它非常讨厌,我曾经在Xcode 7中这样做,这就是为什么我想试试它并且它有效

当我们在Simulator中运行App时,Xcode 8还会打印不需要的日志,这会使调试变得困难

下面是我已经回答过这个问题的链接

click here