• 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
Why not a procedure for retain/release?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why not a procedure for retain/release?


  • Subject: Why not a procedure for retain/release?
  • From: Mark Patterson <email@hidden>
  • Date: Fri, 5 Nov 2004 10:19:26 +1000

Hi,

Since NSObject properties have to be retained and released in their setter methods, I wrote the little procedure replaceProperty demostrated below. Is there any reason against doing this sort of thing? I'm surprised that something done so frequently would be always done in full.

Regards,

Mark

id replaceProperty(id old, id new)
{
  [new retain];
  [old release];
  return new;
}// replaceProperty


//--------------------------------------------------- UCNamed ------------


@implementation UCNamed

-(NSString *) name
{
  return name;
}


-(void) setName: (NSString *) val { name = (NSString *) replaceProperty(name, val); }

@end // UCNamed

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why not a procedure for retain/release?
      • From: mmalcolm crawford <email@hidden>
    • Re: Why not a procedure for retain/release?
      • From: "Ben Kennedy" <email@hidden>
  • Prev by Date: Re: Multiple Documents?! [newbie]
  • Next by Date: what is NSPathStore2
  • Previous by thread: Re: how to get the iTunes look
  • Next by thread: Re: Why not a procedure for retain/release?
  • Index(es):
    • Date
    • Thread