• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Work with AddressBook without blocking the main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Work with AddressBook without blocking the main thread


  • Subject: Re: Work with AddressBook without blocking the main thread
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 26 Apr 2015 00:33:16 +0000

On Apr 25, 2015, at 17:06 , Peter Tomaselli <email@hidden> 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 (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


  • Follow-Ups:
    • Re: Work with AddressBook without blocking the main thread
      • From: Peter Tomaselli <email@hidden>
References: 
 >Work with AddressBook without blocking the main thread (From: Peter Tomaselli <email@hidden>)

  • Prev by Date: Work with AddressBook without blocking the main thread
  • Next by Date: Re: Work with AddressBook without blocking the main thread
  • Previous by thread: Work with AddressBook without blocking the main thread
  • Next by thread: Re: Work with AddressBook without blocking the main thread
  • Index(es):
    • Date
    • Thread