I am making a chat application in iOS. I saved the last conversation of every friend. My core data entity has 3 fields - jID, message and timestamp. I don't set indexing on any field.I just want to fetch the last message of each jID. So,please help me and also tell me whether to set indexing on any field so that fetching process would be appropriate.
Asked
Active
Viewed 192 times
2 Answers
1
You could also add a one-to-one relationship between your entity and the last conversation (you will have to maintain it yourself, if you reveal your model I might be able to be a bit more specific).
A property that is used to filter data, and is used to access elements by, should probably be indexed.
This mean that you probably would want your jID
and timestamp
indexed.

Monolo
- 18,205
- 17
- 69
- 103

Dan Shelly
- 5,991
- 2
- 22
- 26
0
If you want to fetch the last object, you'll need to have them ordered. Timestamp would be fine for this. And if you want to fetch the last object, reverse the ordering and just fetch the first instead.
If you want to use jID
, the ids will have to be in some kind of order.

nevan king
- 112,709
- 45
- 203
- 241