Re: More trouble with NSCollectionView
Re: More trouble with NSCollectionView
- Subject: Re: More trouble with NSCollectionView
- From: "Carter R. Harrison" <email@hidden>
- Date: Wed, 30 Jan 2008 14:33:49 -0500
On Jan 30, 2008, at 2:01 PM, I. Savant wrote:
Maybe it's just me, but I feel like the amount of documentation that
Apple has provided on the new NSCollectionView class and its
associated classes could be a bit more substantial.
File an enhancement request using the feedback boxes at the bottom
of every documentation page. From past experience, it'll take them
awhile to get caught up on useful levels of detail for some of these
new additions to the API. Patience and feedback are both required. The
former for your own sanity and the latter for the documentation team's
own ideas of what to highlight.
Excellent idea. I think I will take advantage of this. Honestly I
wasn't aware that link was even there.
Here's what I'm
trying to accomplish: I have a number of NSManagedObjects, all
belonging to the same entity, and I want the various pieces of data
stored within each one displayed in an NSCollectionView - such that
each subview within the NSCollectionView represents one
NSManagedObject.
This is, if I'm reading this right, almost entirely the "ideal"
situation for which NSCollectionView is intended.
How can I do this programmatically - meaning not in IB?
Frankly, you're making things difficult on yourself and probably for
no good reason. That's an assumption, of course, but there you have
it. Name the really good reason you have for not doing this in IB.
Well maybe I should be doing this in IB. The reason I didn't want to
do this is because I was reading the IB 3.0 User's Guide and it had a
very bare bones sample of how to plug together an NSCollectionView
using bindings. Since my custom view is going to be pulling bits of
data from my managed objects, I knew I would have to create bindings
as part of my view and to do this it looked like I had to go into
palletizing my view for IB. That didn't make a lot of sense to me
since this custom view will not be reused in any additional projects.
I'm thinking I should create an array of NSCollectionViewItems (one
for each managed object that I have), set each item's associated
view,
and then set this array as the content of the NSCollectionView. Does
this sound right or am I totally missing the point here?
Going strictly by the NSCollectionView Class Reference document,
you'd set the collection view's overall content by either calling
-setContent: (and passing in your managed objects, sorted to taste) or
by manually binding its content key to a controller (see the
documentation for establishing manual bindings).
Ok, this helps a lot. I wasn't clear whether or not I was supposed to
be passing in NSCollectionViewItems as the content or my actual
managed objects.
You would create an NSCollectionViewItem and assign it to the
NSCollectionView (via -setItemPrototype:). You would then create your
prototype view (which will be copied by NSCollectionView and managed
for each object it's representing), wire everything up (for example,
bind a text field to the NSCollectionViewItem - the keypath escapes me
at the moment and I'm presently working on a Tiger box), then assign
the view to the NSCollectionViewItem via -setView:
If everything's done properly, you should be up and running.
This makes perfect sense now. So if I do this all correctly, when a
value changes in my managed object, will the view update with this new
data? Seems like it should if I make everything such that it is KVC
and KVO compliant.
--
I.S.
_______________________________________________
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