Re: Confused with block completionHandler
Re: Confused with block completionHandler
- Subject: Re: Confused with block completionHandler
- From: Luke Hiesterman <email@hidden>
- Date: Thu, 25 Aug 2011 00:50:19 +0000
- Thread-topic: Confused with block completionHandler
It looks like you've basically got it with your openPanel example. The only difference in the document example is that the parameter to the block is an NSError*. So, your call would look something like this:
[self saveToURL:[self fileURL] ofType:@"myDocType" forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(NSError* error) {
if (error) {
// do some error handling
}
else {
// do other work
}
}];
Luke
On Aug 24, 2011, at 5:46 PM, Brad Stone wrote:
> I need to call this method manually but I'm confused how to format the completionHandler. I don't understand what I'm reading. Can anyone give me an example of how to define the completionHandler or point me to some documentation?
>
> [self saveToURL:[self fileURL] ofType:@"myDocType" forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(I'm confused!!!)];
>
> This is the method definition
> - (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *errorOrNil))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
> }
>
> Thanks_______________________________________________
>
> 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
_______________________________________________
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