• 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: Clark Cox <email@hidden>
  • Date: Sat, 29 Aug 2009 17:02:09 -0700

That's fine, as you've written it. There is nothing special about the
methods used to implement properties; they're just methods. Wherever
you choose to store the actual data that backs the property is
immaterial.

On Sat, Aug 29, 2009 at 3:39 PM, Todd Heberlein<email@hidden> wrote:
>> 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
>



--
Clark S. Cox III
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

References: 
 >virtual ivars (From: Todd Heberlein <email@hidden>)
 >Re: virtual ivars (From: Kyle Sluder <email@hidden>)
 >Re: virtual ivars (From: Todd Heberlein <email@hidden>)
 >Re: virtual ivars (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: Getting managedObject Context
  • Next by Date: Standard Alert Note/Warning/Stop icon NSImage Names?
  • Previous by thread: Re: virtual ivars
  • Next by thread: Re: virtual ivars
  • Index(es):
    • Date
    • Thread