Yup, that’s my problem exactly. You explained it much better than I could!
To be honest, I don’t have a real good reason for not using the main thread at the moment—it seems fine, performance-wise, for what I am doing. But I was interested in hearing if there was a more performant approach I might be missing, if only to satisfy my curiosity. Most of the info on the web about this is tons of GCD contortions that, from what I can tell, are missing the point. So with respect to spinning up a thread to “keep around”, just point me in the right direction here (this would be new stuff for me): is it NSThread I should look at? Appreciate it, Peter > On Apr 25, 2015, at 8:33 PM, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > > On Apr 25, 2015, at 17:06 , Peter Tomaselli <peter.tomase...@icloud.com > <mailto: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