为什么 Xcode 不显示 CoreData 实体和属性的索引选项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45922314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why Xcode does not show index options for CoreData entities and attributes?
提问by Trzy Gracje
回答by Martin
As @tomharrington said, the solution is in the WWDC 2017 video: Indexing stuff begins at 10:32 and the demo at 16:40.
正如@tomharrington 所说,解决方案在 WWDC 2017 视频中:索引内容从 10:32 开始,演示在 16:40 开始。
It's still possible to create and index via Xcode9:
仍然可以通过 Xcode9 创建和索引:
- First, select your entity, long-click on the + (Add Entity), and select Add Fetch Index.
- 首先,选择您的实体,长按 +(添加实体),然后选择添加提取索引。
Then, name your index appropriately, the select the property you want to index on (and choose ascending or descending, depending on how is organized your data)
Finally, as explained on the video, this will not trigger a migration and user that update your app will not get your index. If you want to force a model migration, add an Hash Modifier by selecting the entity, and setting Right Panel > 3rd tab > Versioning > Hash Modifier.
回答by Tom Harrington
Simple indexing is deprecated in iOS 11, and the Xcode 9 UI reflects that. This is from the docs for NSPropertyDesciption
:
iOS 11 中不推荐使用简单索引,而 Xcode 9 UI 反映了这一点。这是来自以下文档的NSPropertyDesciption
:
At WWDC 2017 the What's New in Core Datasession described a new indexing API. Give that session a look.
在 WWDC 2017 上,Core Data 的新特性会议描述了一个新的索引 API。看看那个会议。