• 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: virtual ivars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: virtual ivars


  • Subject: Re: virtual ivars
  • From: Todd Heberlein <email@hidden>
  • Date: Sat, 29 Aug 2009 15:39:17 -0700

I see from another post I was conflating "ivars" with "properties". With regards to the setters, I have some C++ libraries, and I was thinking about having "property" wrappers in an Objective C object doing setting and getting into values in the C++ object.

So here is a slightly more detailed scenario while still trying to keep it as simple as possible.


My "Model" is captured in C++ code (i.e., "CppObj" below). I want to use normal Cocoa "View" objects (e.g., an NSTextField) and "Controller" objects (e.g., NSObjectController). So I create an Objective C object ("MyWrapper ") to wrap the C++ object, and access to the C++ content is done through "properties". Both the setters and getters reach down into the C++ object to set or get its values.

Things seem to be working. I just wanted to make sure I wasn't doing something illegal or not supported. I guess I have always had properties associated with actual variables, so it never occurred to me before that they are really independent things.

Todd


//----------------- C++ model ---- class CppObj { public: int myInt; };


//----------------- Objective-C++ wrapper ---- @interface MyWrapper : NSObject { CppObj* p_cppObj; } -(int)myInt; -(void)setMyInt:(int)newVal; @end



//----------------- getter/setter wrappers of C++ model ----
-(int)myInt
{
	return p_cppObj->myInt;
}

- (void)setMyInt:(int)newVal
{
	p_cppObj->myInt = newVal;
}


_______________________________________________

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


  • Follow-Ups:
    • Re: virtual ivars
      • From: Uli Kusterer <email@hidden>
    • Re: virtual ivars
      • From: Clark Cox <email@hidden>
References: 
 >virtual ivars (From: Todd Heberlein <email@hidden>)
 >Re: virtual ivars (From: Kyle Sluder <email@hidden>)
 >Re: virtual ivars (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Core Data observer exception in 10.6
  • Next by Date: Getting managedObject Context
  • Previous by thread: Re: virtual ivars
  • Next by thread: Re: virtual ivars
  • Index(es):
    • Date
    • Thread