• 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: mmalcolm crawford <email@hidden>
  • Date: Sun, 2 Jan 2005 09:55:03 -0800


On Jan 2, 2005, at 12:10 AM, Sherm Pendley 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.


That's probably true.

But anyway, if you must use bindings, you might try creating an NSArray subclass and using that in your model.

I don't think this is the best strategy. If you need to present something as an array that isn't, then you can simply implement the relevant indexed accessors in your controller object (the one that holds the model) -- see <http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/Concepts/AccessorConventions.html>.

The main issue, however, is that you have to provide a means of returning a key-value coding-compliant object from each index in the array. This means that you'll probably have to return either an Objective-C proxy for your C++ object, or simply populate a dictionary and return that. If you want the user to edit values, then again you have to translate between the input value and your struct.

mmalc
_______________________________________________
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


References: 
 >Cocoa Bindings and Structures (From: kelvSYC <email@hidden>)
 >Re: Cocoa Bindings and Structures (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: nsbutton
  • Next by Date: Localization + NSGlobalDomain + AppleMeasurementUnits?
  • Previous by thread: Re: Cocoa Bindings and Structures
  • Next by thread: How to use NSLock
  • Index(es):
    • Date
    • Thread