On Apr 25, 2015, at 17:06 , Peter Tomaselli <peter.tomase...@icloud.com> wrote:

> The crux of my problem is that, according to the docs, 
> ABAddressBookRequestAccessWithCompletion’s completion handler “is called on 
> an arbitrary queue”. However, ABAddressBookRequestAccessWithCompletion 
> accepts as an argument an ABAddressBookRef that, presumably, has already been 
> created. 
> 
> I’m not sure how to proceed here. GCD serial queues can guarantee serial 
> access to stuff, but it doesn’t seem like they provide any guarantees about 
> your code executing on any one thread in particular. So, it doesn’t seem like 
> GCD helps me here.

So you won’t be able to issue any AB… API calls from the completion handler 
directly. Instead, you’ll need to know which thread you created the 
ABAddressBookRef on, and arrange to issue the subsequent calls from there.

This is easy if you created the ABAddressBookRef on the main thread, because 
the completion handler can use 'dispatch_async (dispatch_get_main_queue (), …’ 
to get back to the main thread.

What you won’t be able to do is create the ABAddressBookRef via a block 
dispatched to some non-main GCD queue, because you won’t necessarily be able to 
return to the thread the queue was using at the time. In other words, if you 
need to create the ABAddressBookRef on a background thread for some reason, 
you’ll have to do it on a thread you create for yourself, and keep the thread 
around.

But I wouldn’t expect you’d need to create the ABAddressBookRef anywhere but on 
the main thread, right?



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to