• 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: retain/release question about Apple docs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retain/release question about Apple docs


  • Subject: Re: retain/release question about Apple docs
  • From: Julian Cain <email@hidden>
  • Date: Mon, 6 Mar 2006 11:52:54 -0500

What is wrong with using a macro such as :

#define REPLACE(a, b)	if (b != nil) {[b retain]; [a release]; a = b;}	

This is what I always use for  setters.

~Julian Cain
email@hidden



On Mar 6, 2006, at 4:32 AM, Volker Runkel wrote:

Hi James,

the string newValue has to be released since it was retained before creating a copy to mString .

The usual procedure would be :

    if (mString != newValue) {

       //  don't retain here [newValue retain];

        if (mString) [mString release];

        mString = [newValue copy];

        // so don't release here [newValue release];

    }


Volker _______________________________________________ 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

_______________________________________________ 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: retain/release question about Apple docs
      • From: Greg Titus <email@hidden>
References: 
 >retain/release question about Apple docs (From: "James W. Walker" <email@hidden>)
 >Re: retain/release question about Apple docs (From: Volker Runkel <email@hidden>)

  • Prev by Date: binding headertitle
  • Next by Date: Re: retain/release question about Apple docs
  • Previous by thread: Re: retain/release question about Apple docs
  • Next by thread: Re: retain/release question about Apple docs
  • Index(es):
    • Date
    • Thread