Re: Cocoa Classes from C++?
Re: Cocoa Classes from C++?
- Subject: Re: Cocoa Classes from C++?
- From: Chris Hanson <email@hidden>
- Date: Tue, 27 May 2008 19:46:51 -0700
On May 27, 2008, at 5:14 PM, Scott Ribe wrote:
like C++ objects as member
variables of an ObjC object
This works fine if you set the right compiler options, which I think
has
been around since 10.3.
It requires both Mac OS X 10.4 and GCC 4, actually: There is
Objective-C runtime support that this feature needs, and that support
is only in Mac OS X 10.4 and only invoked if you're using GCC 4.0 or
later.
Also, keep in mind that under Objective-C garbage collection, your
objects may be cleaned up -- and therefore your C++ destructors run --
on an arbitrary non-main thread. If you're going to use C++ objects
as instance variables directly, you need to ensure that their
destructors are safe if you're also going to use garbage collection.
Finally, and just as an aside, Objective-C objects have instance
variables (as in Smalltalk) rather than member variables (as in C++).
This is somewhat important to keep straight because various parts of
the framework and runtime will actually use the term. For example,
the method +[NSObject accessInstanceVariablesDirectly] is used to
determine whether key-value coding will look into an object's instance
variables, or whether it will only call an objects property accessor/
mutator methods.
-- Chris
_______________________________________________
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