• 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: Dodgy Code - Low Level Memory Management Question!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dodgy Code - Low Level Memory Management Question!


  • Subject: Re: Dodgy Code - Low Level Memory Management Question!
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 25 Jan 2016 11:22:26 -0800
  • Feedback-id: 167118m:167118agrif8a:167118smBO64LLMx:SMTPCORP

On Jan 25, 2016, at 10:48 , Dave <email@hidden> wrote:
>
> myNewObject = [super initWithSomething: something];

This is a dangerous thing to do. At this point ‘self’ might not be a properly initialized object, if the ‘super’ call returns a different object from ‘self’. You’re better off assigning the result to ‘self’ as usual.

> 	[LTWCacheManager addToCache: myID];

Huh? You’re not passing the object being cached, so how can you get it out of the cache again later? If the ID is a string that contains the object pointer, then at the very least the object isn’t being retained by the cache, is it?

> 	self = myNewObject;
[…]
> 	return self;

> self = myCachedObject;
> return self;

These aren’t really meaningful. Assigning to ‘self’ doesn’t really achieve anything, other than the possibility of getting it wrong. If you want to return an object other than self, then just write ‘return myNewObject’ or ‘return myCachedObject’.

_______________________________________________

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: Dodgy Code - Low Level Memory Management Question!
      • From: Dave <email@hidden>
References: 
 >Dodgy Code - Low Level Memory Management Question! (From: Dave <email@hidden>)

  • Prev by Date: Re: Dodgy Code - Low Level Memory Management Question!
  • Next by Date: Re: Removing Observers eats up memory
  • Previous by thread: Re: Dodgy Code - Low Level Memory Management Question!
  • Next by thread: Re: Dodgy Code - Low Level Memory Management Question!
  • Index(es):
    • Date
    • Thread