Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

enter image description here

  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.

like image 294
Andrew Paul Simmons Avatar asked Oct 24 '17 11:10

Andrew Paul Simmons


People also ask

What is Uri in Core Data?

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.

What are fetched properties in Core Data?

Fetched Properties in Core Data are properties that return an array value from a predicate. A fetched property predicate is a Core Data query that evaluates to an array of results.

What is NSManaged?

NSmanaged is subclass of NSObject. @NSManaged means extra code will be given to these props at runtime. It tracks the changes made to those properties.

What is managed object in Core Data?

A managed object context represents a single object space, or scratch pad, in a Core Data application. A managed object context is an instance of NSManagedObjectContext . Its primary responsibility is to manage a collection of managed objects.


2 Answers

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

New Attribute Types

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.

like image 149
Tom Harrington Avatar answered Sep 20 '22 08:09

Tom Harrington


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.

like image 44
Milan Avatar answered Sep 18 '22 08:09

Milan