Re: Newbie question - core data
Re: Newbie question - core data
- Subject: Re: Newbie question - core data
- From: Stamenkovic Florijan <email@hidden>
- Date: Mon, 14 Sep 2009 09:30:39 -0400
Darren,
On Sep 14, 2009, at 09:11, Darren Wheatley wrote:
Hi,
I'm learning Cocoa / Objective-C. Right now I'm trying to build a
simple Core Data application.
I've built a helper app to read in CSV and populate an XML core data
store. That works fine.
I have seen lots of examples of binding a view to core data entities
so that the contents of the store are loaded into the view when the
application runs. I'm comfortable with how this works.
However, I want my application to start with an empty view, then
have the user enter a search string, and only then display the data
that matches the search string. I know I can use NSPredicate to
filter the data but don't know how to hook it up in this way.
I've read through the Core Data Programming guide, had a look
through Marcus Zarra's book, but I just can't get my head around how
this should work.
Is this something that I can / should do with Core Data? How do I
filter the data before displaying anything in the view?
If anyone could point me at some sample code / articles etc. that
might help fill in the blanks I would appreciate it.
I am also a beginner at CoreData / Cocoa, so what I say below is not
guaranteed to work, and has not been tested...
Assuming you have an NSArrayController that you use in your
interface... You should set "automaticallyPreparesContent" to NO, in
Interface Builder or programatically. Then, after you set the fetch
predicate on the controller, you should invoke either fetch: or
prepareContent: manually on the controller. Not sure about what the
difference between the two would be, look into the docs for info on
this.
Alternatively, you can use your controller as a non-CoreData
controller, and set it's content manually, after you perform a fetch
manually.
HTH,
F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden