• 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: ARC and NSError output parameters: proper declaration?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC and NSError output parameters: proper declaration?


  • Subject: Re: ARC and NSError output parameters: proper declaration?
  • From: Charles Srstka <email@hidden>
  • Date: Mon, 07 Oct 2013 13:57:00 -0500

On Oct 7, 2013, at 1:44 PM, Sean McBride <email@hidden> wrote:

> Hi all,
>
> I understand the issue with NSError output parameters and ARC, and that it automatically 'adds' an __autoreleasing, but I'm wondering what is the recommended way to declare NSError output parameters in new code these days:
>
>
> 1) No decorations, ex:
>
> - (BOOL)foobar:(NSError **)outError;
>
>
> 2) 'out' tag, ex NSKeyValueCoding.h
>
> - (BOOL)validateValue:(inout id *)ioValue forKey:(NSString *)inKey error:(out NSError **)outError;
>
>
> 3) explicit __autoreleasing
>
> - (BOOL)foobar:(NSError * __autoreleasing *)outError;
>
>
> Which is preferable?  I'm interested both in term of correctness and style/coding standards.

If you know the clients of your code are always going to be using ARC, you could use (NSError * __strong *). This would slightly reduce the number of autoreleased objects you generate, as well as prevent crashes caused by things like this:

- (BOOL)foo:(NSError * __autoreleasing *)error {
	@autoreleasepool {
		return [someObject bar:error];
	}
}

Charles


_______________________________________________

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


References: 
 >ARC and NSError output parameters: proper declaration? (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: Infinite Scroll View?
  • Next by Date: Question about menuHasKeyEquivalent:forEvent:target:action:
  • Previous by thread: ARC and NSError output parameters: proper declaration?
  • Next by thread: Question about menuHasKeyEquivalent:forEvent:target:action:
  • Index(es):
    • Date
    • Thread