|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
On Wed, 29 Jun 2011 12:53:26 +0200, Markus Hanauska <email@hidden> said: >E.g. consider the following code: > > ObjectCreator oc = [[ObjectCreator alloc] init]; > id value = [oc value]; > [oc release]; > [value someMethod]; > We actually had something very like this discussion here already recently: http://lists.apple.com/archives/cocoa-dev/2011/Mar/threads.html (Look at the thread titled "NSAttributedString crashes".) As I said then, "Ownership is *never* something you are magically given. It is always something that you must take if you want it." Perhaps that answer isn't very satisfactory, but at least it provides a philosophy that covers the case. As Andy Lee says in that same thread, "We've been conditioned to think we have "extra persistence time" at least up to the next run loop iteration," but (I think he's implying) this conditioning is specious and serves only to make us lazy. To put it another way: ObjectCreator's "value" method is opaque; to pretend that you *know* its memory-management policy is really just a case of programming by guesswork. m. -- matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/> A fool + a tool + an autorelease pool = cool! Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook_______________________________________________ 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
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.