Re: Using Bindings with C++ objects
Re: Using Bindings with C++ objects
- Subject: Re: Using Bindings with C++ objects
- From: Uli Kusterer <email@hidden>
- Date: Sun, 23 Dec 2007 17:23:04 +0100
Rick,
I doubt you'd gain anything from using bindings in your case. The
code you'd have to write to bridge your C++ objects would essentially
be the same as you'd have to write to implement your master-detail-
view without bindings.
Bindings are so useful because they can introspect into ObjC objects.
Without that, bindings are just a complication on top of MVC, and
don't get you anything.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
Am 22.12.2007 um 23:53 schrieb Rick Mann <email@hidden>:
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