Recent Searches Using Master Data

I'm making a Core Data app for iPhone, but hope this question will be enough for Mac OS X to be answered in this context with no NDA issues.

When the user searches, I store each result in context using an object record. I want these results to be retrieved later in the Recent Searches section. What's the best way to do this?

One way I am considering is to add another object named History with an Entry attribute associated with it. The first search results would have Entry.history_id = 1, the second would have Entry.history_id = 2, etc. Then Recent Searches will select the Entity with the specified history id.

0


a source to share


1 answer


If you want an ordered list of searches, then you're right: you'll have to manually manage some property that defines the order. history_id

you give one opportunity. I would probably use the date attribute, which is set when an object instance is inserted. Then you can order your selection using the date property. To store the actual lookup, I've often serialized the NSPredicate instance to query as a data property (handling serialization / deserialization myself) or transformable (using the default NSUnarchiveFromData transfer property).



0


a source







All Articles