Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Confused with block completionHandler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confused with block completionHandler



-----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

References: 
 >Confused with block completionHandler (From: Brad Stone <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.