• 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: monitoring changes in a local property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: monitoring changes in a local property


  • Subject: Re: monitoring changes in a local property
  • From: Eeyore <email@hidden>
  • Date: Mon, 07 May 2012 20:50:36 -0700

Roland's right about ARC, you just need the set and copy. Just for the record, I don't think the pattern you present is safe when newSelection equals mySelection (as you release before you copy), you need something like one of the following:

if (mySelection != newSelection)
{
	[mySelection release];
	mySelection = [newSelection copy];
}

OR

[mySelection autorelease];
mySelection = [newSelection copy];

OR

oldSelection = mySelection;
mySelection = [newSelection copy];
[oldSelection release];

Aaron

On May 7, 2012, at 8:38 PM, Koen van der Drift wrote:

>
> On May 7, 2012, at 11:28 PM, Roland King wrote:
>
>> -(void)setMySelection:(NSArray*)newSelection
>> {
>> 		// set whatever instance variable you have for mySelection, with appropriate memory management if necessary
>
>
> I thought about that too, but how do I do that when using ARC? Can I still do this:
>
> [mySelection release];
> [mySelection = [newSelection copy]];
>
> or something along those lines?
>
> - Koen.
> _______________________________________________
>
> 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
>


_______________________________________________

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: 
 >monitoring changes in a local property (From: Koen van der Drift <email@hidden>)
 >Re: monitoring changes in a local property (From: Roland King <email@hidden>)
 >Re: monitoring changes in a local property (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: monitoring changes in a local property
  • Next by Date: Re: monitoring changes in a local property
  • Previous by thread: Re: monitoring changes in a local property
  • Next by thread: Re: monitoring changes in a local property
  • Index(es):
    • Date
    • Thread