Re: spaghetti code with core data and multiple views
Re: spaghetti code with core data and multiple views
- Subject: Re: spaghetti code with core data and multiple views
- From: Christopher Campbell Jensen <email@hidden>
- Date: Tue, 14 Jul 2009 17:15:32 +0200
In addition to the previous post from Mr Quincey Morris, I received
the following from Aaron:
Hi Chris,
I'm having troubles posting to the list so this is a private
response, but feel free to use any of this email on-list if you want
to.
I haven't read your entire email, but the impression I got from what
I skimmed through sounds like you should at least make yourself
familiar with the NSArrayController. It has set of content objects
(e.g., your objects managed by the managed object context) and
allows you to apply a filter to "narrow down" the list of objects (I
suggest you use the term "filtered", IMHO). You can also supply
sort descriptors to the array controller. The result of filtering
and sorting the content objects is the arranged objects. The
arranged objects could be read and acted on, or supplied as the
content to another array controller, if needed.
So, to put it into context of a GUI, you could give an array
controller a set of managed objects, connect a search field to the
filter property, and connect an NSTableView to the arrangedObjects
to show the result. The table view can supply sort descriptors to
the array controller.
If the array controller class isn't exactly what you need, it may at
least give you some ideas on how to cleanly design what you need.
For example, maybe you need more complex filtering, so you might
have a utility window with text fields, check boxes, etc, that go
into building an appropriate predicate to filter your objects.
BTW, I've read two of Quincy's replies, too, and I agree with his
suggestions. Also, I suggest playing with some examples or creating
your own outside of your main project. In the long run, it is much
easier to try out concepts in isolation, and you will be less
frustrated overall.
HTH,
Aaron
I wanted to thank both of you for putting thought and effort into
providing me with valuable guidance and advice. You are both very
right in that I am trying to cross the boundaries between the Model
and the View, which would ruin all the hard work I have put into doing
things "right". I will now take a step back and reevaluate my options.
Step one will be to try and learn a bit more about core data, and I
will be creating a few smaller, simpler apps to test things out. In
addition I will be working through some tutorials to see if I can see
any solutions to my issues.
If that does not pan out, then I will start looking at pure database
based solutions.
Some initial investigation on that side brought me to:
http://code.google.com/p/entropydb/
The ability to store objective-c objects in an sqlite db might be just
up my alley; or alternatively I can do it the good old fashion way and
do all the work myself ;)
Additional comments or advice is always welcome!
_______________________________________________
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