Re: NSAttributedString crashes
Re: NSAttributedString crashes
- Subject: Re: NSAttributedString crashes
- From: Andy Lee <email@hidden>
- Date: Thu, 03 Mar 2011 23:09:35 -0500
On Mar 3, 2011, at 1:10 PM, Matt Neuburg wrote:
> So what I'm trying to show you is that when you've got an object that owns stuff, you *never* expect that that object will dispense the stuff it owns while handing you a share in ownership.
I would argue it's irrelevant whether the dispensing object owns what it dispenses. True, you'll have a pretty good idea whether it does or not, but not always. Suppose I have
NSString *fn = [aPerson fullName];
I don't necessarily know whether aPerson owns the object referenced by fn, and I don't care. "fullName" does not contain "new", "alloc", or "copy", so the memory management rules say I must retain fn if I want it to stick around.
As for what "stick around" means...
> You *always* take ownership if you want that stuff to persist beyond the object that dispenses them.
...I don't think I've ever heard the phrasing, "beyond the object that dispenses them". We've been conditioned to think we have "extra persistence time" at least up to the next run loop iteration. I think this stronger assertion is better and addresses the issue at hand.
--Andy
_______________________________________________
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