• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Bindings and Structures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Bindings and Structures


  • Subject: Re: Cocoa Bindings and Structures
  • From: Sherm Pendley <email@hidden>
  • Date: Sun, 2 Jan 2005 03:10:42 -0500

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa Bindings and Structures
      • From: mmalcolm crawford <email@hidden>
References: 
 >Cocoa Bindings and Structures (From: kelvSYC <email@hidden>)

  • Prev by Date: Cocoa Bindings and Structures
  • Next by Date: How to use NSLock
  • Previous by thread: Cocoa Bindings and Structures
  • Next by thread: Re: Cocoa Bindings and Structures
  • Index(es):
    • Date
    • Thread