+3  A: 

Yes, Snow Leopard makes this much easier. In IB, click on the NSCollectionViewItem and set the nib name and bundle name (just leave it blank for the main bundle). In your PersonView nib, make the NSCollectionViewItem the File's Owner and connect the -view outlet to a view in that nib. (It looks like you might have this set up like that already in that nib.) Everything else should be automatic, and overriding copyWithZone: shouldn't be necessary.

kperryua
Thanks. It's showing up now, but I can't access the outlets I binded to the FileOwner of the nib that contains the Item's View. Do I have to do that differently now too?
André Hoffmann
I'm not sure what you mean. Can you elaborate?
kperryua
I edited my answer to show you what I mean.
André Hoffmann
Did you make sure that both your File's Owner AND the prototype item are both declared as instances of your subclass? If the prototype item is still NSCollectionViewItem, then the copied items will be of that same class, not your custom class. (I ran into the same problem while trying to reproduce what you described.)
kperryua
Yes, I have changed both of them. See my second update for details.
André Hoffmann
I really can't say what you should do next. I've replicated your scenario and made sure to do everything I suggested to do, and it works for me. Give everything a second pass and make sure you've done everything. Perhaps try breaking on -[NSCollectionViewItem copyWithZone:] in the debugger, root out the pointer to 'self' ($esi I think on x86_64, $ebp+8 on i386, and check the class. If it's still NSCollectionViewItem, you know you missed something.
kperryua
A: 

To sync the property of the representedObject with the Value of an IB Element, you might want to use the Cocoa-bindings. Bind the Value of the TextField to the Model Key Path representedObject.name of the File's Owner in this case.

I had that working with 10.6 Xcode 3.2 but what can't get to work is what you did: Connecting an IB Element to an Outlet of my CollectionViewItem. I have a custom subclass of CollectionViewItem and everything set up as you have. But when running the application it fails stating

[NSTextField copyWithZone:]: unrecognized selector sent to instance 0x210a60 2009-10-19 13:05:18.772 WrapperTest[24122:a0f] An uncaught exception was raised 2009-10-19 13:05:18.774 WrapperTest[24122:a0f] -[NSTextField copyWithZone:]: unrecognized selector sent to instance 0x210a60 2009-10-19 13:05:18.779 WrapperTest[24122:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTextField copyWithZone:]: unrecognized selector sent to instance 0x210a60' *** Call stack at first throw: ( 0 CoreFoundation 0x977f658a __raiseError + 410 1 libobjc.A.dylib 0x9767ff49 objc_exception_throw + 56 2 CoreFoundation 0x978429db -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x9779e026 ___forwarding___ + 950 4 CoreFoundation 0x9779dbf2 _CF_forwarding_prep_0 + 50 5 CoreFoundation 0x97789a5a -[NSObject(NSObject) copy] + 42 6 AppKit 0x918ce1d7 -[NSViewController setTitle:] + 70 7 AppKit 0x91167dab -[NSNibOutletConnector establishConnection] + 406 ...

I'm not sure why those NSTextFields are missing their copyWithZone since they should implement it

I fixed that, I wasn't aware, that I needed to declare those Outlets as properties of the view, everything including bindings seem to work.

Lennart