• 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: Properties and memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properties and memory management


  • Subject: Re: Properties and memory management
  • From: Marcel Weiher <email@hidden>
  • Date: Wed, 6 Aug 2008 00:10:03 -0700


On Aug 5, 2008, at 15:28 , Uli Kusterer wrote:

On 05.08.2008, at 22:24, Marcel Weiher wrote:
On Aug 5, 2008, at 2:57 , Uli Kusterer wrote:

Lucky then, that I adopted GNUstep-style ASSIGN() and DESTROY() macros for these purposes, and since most of my code still needs to be 10.4-compatible, I've mostly been using those:

So why not go one step further and let macros generate the accessor for you (of course using the ASSIGN() macro inside those generated accessors)?

Well, I'm using ASSIGN in the mutators. Did you have an even more cunning plan that would work?

I am not sure it is cunning, but it's been working for over a decade: have macros to generate the accessors for you.



----- snip ------ #define setAccessor( type, var,setVar ) \ -(void)setVar:(type)newVar { \ ASSIGN_ID(var,newVar)\ } \

#define readAccessor( type, var )\
-(type)var { return var; }


#define objectAccessor( objectType, var, setVar ) \
readAccessor( objectType, var )\
setAccessor( objectType, var,setVar )

#define idAccessor( var, setVar ) objectAccessor( id, var, setVar )
-----   snip   ------

So to create the accessors for "myVar", just write

idAccessor( myVar, setMyVar )


Cheers,

Marcel



_______________________________________________

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: 
 >Properties and memory management (From: Mike Manzano <email@hidden>)
 >Re: Properties and memory management (From: Jonathan Hess <email@hidden>)
 >Re: Properties and memory management (From: Uli Kusterer <email@hidden>)
 >Re: Properties and memory management (From: "Ken Ferry" <email@hidden>)
 >Re: Properties and memory management (From: Negm-Awad Amin <email@hidden>)
 >Re: Properties and memory management (From: Uli Kusterer <email@hidden>)
 >Re: Properties and memory management (From: Marcel Weiher <email@hidden>)
 >Re: Properties and memory management (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Rotate NSString... I give up :(
  • Next by Date: Re: "backporting" nibs question / Rhapsody license anyone?
  • Previous by thread: Re: Properties and memory management
  • Next by thread: Re: Properties and memory management
  • Index(es):
    • Date
    • Thread