Re: Confused with block completionHandler
Re: Confused with block completionHandler
- Subject: Re: Confused with block completionHandler
- From: Conrad Shultz <email@hidden>
- Date: Wed, 24 Aug 2011 17:58:31 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 8/24/11 5:46 PM, Brad Stone wrote:
> This is the method definition - (void)saveToURL:(NSURL *)url
> ofType:(NSString *)typeName
> forSaveOperation:(NSSaveOperationType)saveOperation
> completionHandler:(void (^)(NSError *errorOrNil))completionHandler
This indicates it is expecting a block with no return value and
accepting one argument, a pointer to an NSError.
So you would pass in something like:
^(NSError *error) { // Do something with error if present }
as the completionHandler.
> I've used blocks before like below but I don't understand the
> syntax above and I couldn't find an example on the internet or the
> documentation. Any help would be appreciated. [openPanel
> beginSheetModalForWindow:[NSApp keyWindow]
> completionHandler:^(NSInteger theResult) { if (theResult) { // some
> code here }
This is very similar to the above.
I recommend
http://developer.apple.com/library/ios/#featuredarticles/Short_Practical_Guide_Blocks/_index.html.
- --
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFOVZ43aOlrz5+0JdURAl7eAJ4t2zkF12CQxjgTLiYPmMyDesJGEgCfT7zS
0uiVWwR5cNFVYwNvjyLVlAg=
=Kj0v
-----END PGP SIGNATURE-----
_______________________________________________
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