Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Bindings and Structures



On Jan 1, 2005, at 8:55 PM, kelvSYC wrote:

I have an array (actually, a std::vector) of structures (actually, C++ classes) that I would like to display in an NSTableView (with each column representing a different property of the strucutre. What would be the best strategy to do so with Cocoa Bindings?

Seems to me that just writing controller data source methods that fetch/store data using the C++ array would be easier.


But anyway, if you must use bindings, you might try creating an NSArray subclass and using that in your model. In your subclass, store a reference to the C++ array as an instance variable, and access that in your version of the required primitive methods. NSArray is a member of a class cluster, so subclassing is seldom recommended - as a rule of thumb, I only do so when I'd be overriding the primitive methods anyway, to provide a custom low-level data storage while keeping the standard NSArray interface.

The primitive methods you need to override are listed in the NSArray & NSMutableArray docs. If you'd like an example of an NSArray subclass that acts as a wrapper around a "foreign" array, have a look at the CBPerlArray class in CamelBones. Link's in my .sig.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Cocoa Bindings and Structures (From: kelvSYC <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.