• 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: iOS - Help with nasty memory leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iOS - Help with nasty memory leak


  • Subject: Re: iOS - Help with nasty memory leak
  • From: Joar Wingfors <email@hidden>
  • Date: Sat, 27 Nov 2010 08:50:27 -0800

On 27 nov 2010, at 06.33, Philip Vallone wrote:

> 		if ((self = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier])) {
> 			[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
> 		}


You're replacing the current instance with a new instance here. Is that intended? While not illegal, it is really unusual to do that.

If that's intended, you also would have to release the old instance before replacing it with the new instance (that's the leak). If that was not intended, you probably should be calling [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier], and in any case, you need to make sure that you *always* call through to the designated initializer of your superclass somewhere in your init method.

Finally, why are you calling a method using "-performSelector:withObject:" here? That seems like a trick to "fix" a compiler warning? If so, you should think about why the compiler were warning you about that call, and fix it properly - by adding the required #import statement, by adding the missing method declaration to the header, or - if all else fails - by casting the receiver to the appropriate type.


j o a r


_______________________________________________

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

  • Follow-Ups:
    • Re: iOS - Help with nasty memory leak
      • From: Philip Vallone <email@hidden>
References: 
 >iOS - Help with nasty memory leak (From: Philip Vallone <email@hidden>)

  • Prev by Date: Re: NSTask with unzip
  • Next by Date: Re: NSTask with unzip
  • Previous by thread: iOS - Help with nasty memory leak
  • Next by thread: Re: iOS - Help with nasty memory leak
  • Index(es):
    • Date
    • Thread