Re: How to call on id
Re: How to call on id
- Subject: Re: How to call on id
- From: Graham Cox <email@hidden>
- Date: Thu, 25 Feb 2010 14:54:38 +1100
On 25/02/2010, at 2:43 PM, David Blanton wrote:
> I misspoke earlier.
>
> What I want to do is access an an ivar in m_view such as m_cpp wher m_cpp is an instance of a C++ class and then call functions on m_cpp such as
>
> m_view->m_cpp.Function()
>
> but I get 'struct objc_object' has no member named 'm_cppr'
>
> My apologies for not being precise earlier !
First I think accessing the ivars of an object directly is to be discouraged. To do it you'd have to make the ivar public (they are protected by default) and that breaks encapsulation.
Instead make an accessor for the ivar. That will fix the first problem of how to call the accessor:
DBView* view;
[view myCPlusPlusThing];
The next problem is what type does the accessor return? Why not just let it return the real type? Then you can call it directly as a C++ object provided that you're using .mm files in all places that the hosting object is used and requires access to this.
--Graham_______________________________________________
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