• 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: ARC vs Manual Reference Counting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC vs Manual Reference Counting


  • Subject: Re: ARC vs Manual Reference Counting
  • From: Marcel Weiher <email@hidden>
  • Date: Tue, 10 Sep 2013 23:09:43 +0200

On Sep 10, 2013, at 21:52 , Ken Thomases <email@hidden> wrote:

> On Sep 9, 2013, at 3:49 AM, Marcel Weiher wrote:
>
>> The pattern I adopted long ago to avoid that sort of situation is to have an instance variable for my temps, in which case the code becomes:
>>
>> 	[self setTemp:newObject];
>> 	… do stuff …
>> 	[self setTemp:nil];
>>
>> or if you prefer dot syntax:
>>
>> 	self.temp = newObject;
>> 	… do stuff …
>> 	self.temp = nil;
>>
>> Even if you forget nilling, you at most have an extended lifetime of an object, not a leak.  I also generally do the same in initialization code (but not in dealloc).  For me, that simply got rid of reference-counting pain.  Completely.  Memory management is mediated by accessors, always.  And accessors are generated.
>
> This technique is not safe for reentrant methods,

Hi Ken,

I should have been more clear:  this technique is not needed for ordinary methods or ordinary local variables.  I use it for those types of methods that are run asynchronously and that therefore want to retain a temp.  Those sorts of methods are not re-entrant anyhow.

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: 
 >ARC vs Manual Reference Counting (From: email@hidden)
 >Re: ARC vs Manual Reference Counting (From: Patrick Cusack <email@hidden>)
 >Re: ARC vs Manual Reference Counting (From: Jens Alfke <email@hidden>)
 >Re: ARC vs Manual Reference Counting (From: Alex Kac <email@hidden>)
 >Re: ARC vs Manual Reference Counting (From: Kyle Sluder <email@hidden>)
 >Re: ARC vs Manual Reference Counting (From: Marcel Weiher <email@hidden>)
 >Re: ARC vs Manual Reference Counting (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: 64-bit iOS
  • Next by Date: Re: 64-bit iOS
  • Previous by thread: Re: ARC vs Manual Reference Counting
  • Next by thread: Re: ARC vs Manual Reference Counting
  • Index(es):
    • Date
    • Thread