Re: More trouble with NSCollectionView
Re: More trouble with NSCollectionView
- Subject: Re: More trouble with NSCollectionView
- From: "I. Savant" <email@hidden>
- Date: Wed, 30 Jan 2008 14:01:03 -0500
> 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.
> 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.
> 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).
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.
--
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