Actually, you can still give this a try. The Leopard-style NSCollectionViewItem was restricted to replicating just the prototype view so the array controller the prototype view was bound to would not be replicated. Since SnowLeopard uses a nib for the prototype view, the entire nib will be replicated each time a new NSCollectionViewItem is instantiated, hence it can create one array controller per item view.
Using this approach, you can still support Leopard by overriding -newItemForRepresentedObject: and instantiating the same nib yourself, instead of using the view replication implementation provided by NSCollectionView. -Kevin On Mar 23, 2010, at 9:30 PM, Brian Krisler wrote: > Since I am testing this in a sample app as a proof-of-concept, I have > a single nib. Plus I have a requirement to support Leopard, so applying > Snow Leopard specific code is not an option. > > After some further investigation, I thing the issue is with my > NSArrayController > object in my nib file. What I would really want is an NSArrayController > for each view within the CollectionView, however it appears to me that this > is not what is actually happening. I think that when I bind my > NSCollectionViewItem > representedObject.blockItems to my NSArrayController, this does not create > a unique array controller for each CollectionViewItem. > > I think my option is to create my layout by hand and give up on attempting to > use an NSCollectionView. I was thinking the collection view would save me > some work. Appears to not be the case. > > Thanks for the assistance. > > Brian > > ----- Original Message ----- > From: "Kevin Perry" <[email protected]> > To: "Brian Krisler" <[email protected]> > Cc: [email protected] > Sent: Tuesday, March 23, 2010 12:07:03 PM GMT -05:00 US/Canada Eastern > Subject: Re: Attempt to nest an NSCollectionView fails. > > I'm not sure this is really a usage case that I'd expect to be well tested, > since it seems a little out of the ordinary. > > Anyway, which approach are you using for your prototype view? Is the view in > the same nib, or have you factored it out into a separate nib, using the fact > that NSCollectionViewItem became a subclass of NSViewController in Snow > Leopard? If you're using the former, then the bindings may very well not be > transferred correctly to each replicated view. Either switch to the Snow > Leopard approach (highly recommended -- see the AppKit release notes for more > details), or you can try overriding -newItemForRepresentedObject: and set up > the bindings yourself. > > -Kevin > > On Mar 22, 2010, at 8:31 PM, Brian Krisler wrote: > >> Hi, >> >> I am trying to nest an NSCollectionView inside an existing collection view >> and am not having much luck. The example I am building runs without issue, >> however the nested values do not appear. >> >> I currently have two model classes: >> >> @interface BlockModel : NSObject { >> NSString *blockTitle; >> NSMutableArray *blockItems; >> } >> @property (readwrite, retain) NSString *blockTitle; >> @property (readwrite, retain) NSMutableArray *blockItems; >> @end >> >> and >> >> @interface BlockItem : NSObject { >> NSString *itemName; >> NSString *itemDescription; >> } >> @property (readwrite, retain) NSString *itemName; >> @property (readwrite, retain) NSString *itemDescription; >> @end >> >> In my delegate, I have an NSMutableArray of blockModels. >> >> Then in Interface Builder, I have an NSCollection view with a label and a >> nested NSCollection view. The label contains the BlockModel.blockTitle >> (which displays correctly). >> >> To get content into the nested view, I have an Array Controller with the >> Content Array bound to the Collection View Item from the parent and a model >> Key Path of: representedObject.blockItems >> >> My nested collection view has its content bound to my Array Controller >> arrangedObjects. And my array controller is configured to be an object >> controller with the keys: itemName and itemDescription. I then have two >> labels in my nested collection view bound to the nested collection view item >> representedObject.itemName and representedObject.itemDescription. >> >> When I execute my code, I can see a few blocks with the proper titles, >> however the nest view is completely empty. >> >> Is there a step that I am missing? >> >> Thanks for any help. >> >> Brian >> _______________________________________________ >> >> Cocoa-dev mailing list ([email protected]) >> >> 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: >> http://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com >> >> This email sent to [email protected] > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
