Core Data中的R-Tree索引... pre-iOS 11的向后兼容性?

问题描述:

我注意到在iOS 11上有Core Data的R-Tree索引。如果创建了这个索引,那么该模型是否与较低的iOS版本不兼容?或者,它被忽略了吗?Core Data中的R-Tree索引... pre-iOS 11的向后兼容性?

https://developer.apple.com/documentation/coredata/nsfetchindexelementtype/2887046-rtree

是,那么这个模型是不兼容的。我唯一没有发现的是如何编译低于iOS 11的目标的模型,以便与苹果在其Release Notes中陈述的旧世界兼容。

我现在的解决方法是让SDK自动推断映射模型:

NSDictionary *pscOptions = @{ 
      NSMigratePersistentStoresAutomaticallyOption : @YES, 
      NSInferMappingModelAutomaticallyOption  : @YES, 
      NSSQLitePragmasOption : @{ @"journal_mode" : @"WAL"}//iOS >=7 Default behaviour 
    }; 

[self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType 
                 configuration:nil 
                   URL:[self sourceStoreURL] 
                  options:pscOptions 
                   error:&error]