Utsav Dusad
Utsav Dusad

Reputation: 2199

What is the transient, indexed, index spotlight and store in external Record file in core data?

I want to know when to use below properties? What do they do? Why should we use it?

  1. Transient: According to Apple Docs:

Transient attributes are properties that you define as part of the model, but which are not saved to the persistent store as part of an entity instance’s data. Core Data does track changes you make to transient properties, so they are recorded for undo operations. You use transient properties for a variety of purposes, including keeping calculated values and derived values.

I do not understand the part that it is not saved to the persistent store as an entity instance's data. Can any one explain this?

  1. indexed: It increase the search speed but at the cost of more space. So basically, if you do a search query using an attribute and you want faster result then make that property as 'indexed'. If the search operation is very rare then it decreases the performance as it take more space for indexing. I am not sure whether it is correct or not?
  2. index in spotlight
  3. Store in External record file

Upvotes: 3

Views: 2246

Answers (1)

Alex Curylo
Alex Curylo

Reputation: 4770

  1. Consider for instance that you have a navigation app. On your map you have your car at the center, updated a few dozen times a second, and an Entity of the type "GAS STATION". The entity's property 'distance' from your car would be a transient property, as it is a function of real time data thus there's no point to storing it.

  2. An indexed attribute is stored sorted, therefore it can be searched faster. Explanation can be found on Wikipedia. If your frequent searches take noticeable time, you should probably consider indexing.

  3. Consider indexing in Spotlight anything the user is likely to want to search for when not within your application. Documentation is here.

  4. Large binary objects, like images, should be stored externally.

Upvotes: 1

Related Questions