Re: Using Bindings with C++ objects
Re: Using Bindings with C++ objects
- Subject: Re: Using Bindings with C++ objects
- From: "Mac Developer" <email@hidden>
- Date: Wed, 26 Dec 2007 20:01:07 -0800
Using bindings for anything other than MODEL <--> VIEW is not recommended by
Apple...
See this message:
http://lists.apple.com/archives/Cocoa-dev/2005/May/msg02490.html
On May 26, 2005, at 7:39 PM, mmalcolm crawford wrote:
After all the other writing I omitted the main point:
You typically should not bind one model object to another. The primary goal
of bindings is to keep user views synchronised with models. You bind an
attribute of a UI widget to the property of a model object...
If you find yourself doing anything different than binding an attribute of a
UI widget to the property of a model object, then you're probably going to
get into more trouble than you would expect.
On Dec 22, 2007 2:53 PM, Rick Mann <email@hidden> wrote:
> I have an existing Carbon app that I'm trying to port to Cocoa. I
> don't want to rewrite everything as an Obj-C object, so I'm looking
> for ways to wrap Cocoa around my C++.
>
> In one situation, I have a C++ object that represents a Satellite, and
> another that is a SatelliteProxy. In the app, there is a master list
> of Satellite objects, and a SatelliteProxy for each satellite in each
> view that's displaying satellites. The proxy object overrides some of
> the attributes of the graphical representation of a Satellite. For
> example, in one view, the International Space Station (ISS) may have a
> red ground track, and in another view, a green ground track. In this
> instance, there are two ISS SatelliteProxy objects that each refer to
> the single, global (app-wide) ISS Satellite object.
>
> The user can select SatelliteProxy objects (one or many) in a view,
> then use an inspector to adjust their attributes.For example, if an
> attribute is "Show footprint" (the footprint is the area of the Earth
> that has line-of-site to the satellite at a given instant), and two
> satellites are selected, one with the footprint enabled, the other
> not, the checkbox in the inspector would show a dash. Similarly, if
> both satellites had the footprint enabled, the box would show as
> checked (standard multi-object inspector behavior).
>
> I'd like to use bindings to facilitate this (as I understand it, this
> is something they're good for). However, they won't work directly on C+
> + objects. I was thinking I could subclass NSArrayController and
> override the valueForKey: methods to manually inspect the key path and
> hard-code queries to the SatelliteProxy objects. One of my concerns
> with this approach is that the NSArrayController's container for the
> collection of SatelliteProxy objects may not be able to contain C++
> objects.
>
> I'd like to get feedback on this approach. Is it viable? It's okay if
> there's extra effort coding up the key-to-C++ mapping. That's still
> less work than rewriting my classes as Obj-C.
>
> An alternative is to create a wrapper Obj-C object, one for each
> SatelliteProxy object. I do something similar for the view code I
> wrote in the Carbon app.
>
> Suggestions?
>
> TIA,
> Rick
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden