On Jan 30, 2013, at 1:25 AM, Greg Parker <[email protected]> wrote: > Name the method `new...` instead of `create...`. Otherwise you do suffer an > autorelease penalty with ARC. (`create...` is not one of the names that ARC > assumes will return a retained result.)
Huh? I thought ARC generated objc_autoreleaseReturnValue in this case, which peeks up the stack to see if the caller is calling objc_retainAutoreleasedReturnValue on it, and refrains from autoreleasing the object if it does. It seems to me that you'd have an autorelease penalty if the caller is not using ARC, but you wouldn't have one if it is. On Jan 30, 2013, at 1:40 AM, Quincey Morris <[email protected]> wrote: >> Return `(instancetype)` instead of `(id)` or `(Bla *)`. Otherwise you won't >> work well with subclasses. (The compiler will assume instancetype if your >> method is named `new...`, but not if you use some other name.) > > That one's new to me. Completely undocumented on developer.apple.com, I > notice. Which Xcode has the clang that has it? http://clang.llvm.org/docs/LanguageExtensions.html Look under "Related Result Types." It's an extremely nice feature. You can call methods on the returned object and get type checking, autocomplete, the whole shebang. Even dot notation works. I *think* Xcode 4.2 was the one that introduced it, but my memory's not 100% on that. Charles _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
