In Core Data, what is the URI property type on the NSManaged object supposed to be used for?

[亡魂溺海] 提交于 2020-01-22 14:19:26

问题


  1. Why would you need the URI type?
  2. What is the equivalent Swift object type for a URI property?
  3. Would I store a URL in this property?
  4. I'm doubtful that I would ever want to store the URI for another managed object in this way, but is it related?

Also, a link to any Apple docs that describe the usage would be helpful.


回答1:


In the WWDC 2017 "What's New in Core Data" session, one of the slides indicates:

Why would you need the URI type?

To store a URL.

What is the equivalent Swift object type for a URI property?

The Swift equivalent of NSURL is URL.

Would I store a URL in this property?

That is the purpose of the type.

I'm doubtful that I would ever want to store the URI for another managed object in this way, but is it related?

Possible, but probably not a good idea. A relationship would be better. Still, there might be cases where it makes sense to do this.




回答2:


You can use URI to store URL of image, audio, video or any other resource. In case, you store images on the device in files, you can use URL of the file path.



来源:https://stackoverflow.com/questions/46909519/in-core-data-what-is-the-uri-property-type-on-the-nsmanaged-object-supposed-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!