Re: UIDocument openWithCompletionHandler: called on what thread?
Re: UIDocument openWithCompletionHandler: called on what thread?
- Subject: Re: UIDocument openWithCompletionHandler: called on what thread?
- From: Luke Hiesterman <email@hidden>
- Date: Mon, 03 Sep 2012 16:09:29 +0000
- Thread-topic: UIDocument openWithCompletionHandler: called on what thread?
The documentation isn't entirely accurate. The completion handler will only be executed on the main queue if you call the method on the main queue. In general, the completion handler is executed on the same queue that the constituent method was called on.
Luke
On Sep 3, 2012, at 6:29 AM, "Roland King" <email@hidden> wrote:
> Here's a small snippet from the docs for UIDocument's openWithCompletionHandler:
>
> Parameters
> completionHandler
> A block with code to execute after the open operation concludes. The block returns no value and has one parameter:
> success
> YES if the open operation succeeds, otherwise NO.
>
> The block is invoked on the main queue.
>
> I have a subclass of UIDocument, this is my openWithCompletionHandler override, I need to cache something at the point the document is opened and closed ..
>
> -(void)openWithCompletionHandler:(void (^)(BOOL))completionHandler
> {
> // after the open, recalcuate the topic
> [ super openWithCompletionHandler:^(BOOL success){
> [ self cacheTopic ];
> if( completionHandler )
> completionHandler( success ); // <-- I'm here
> } ];
> }
>
>
> I'm in the debugger right now at the 'completionHander( success )' call and I'm on Thread 11. That is not the main thread, harder to show but if I type this into LLDB ..
>
> (lldb) p (BOOL)[ NSThread isMainThread ]
> (BOOL) $2 = NO
> (lldb)
>
> Is there something entirely braindead I am missing here or should I be on the main queue and thus on the main thread if the documentation is correct?
>
>
>
>
>
> _______________________________________________
>
> 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