> On Sep 28, 2015, at 3:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
> I have problem with NSThread subclass. It's very similar to this case - 
> http://prod.lists.apple.com/archives/cocoa-dev/2015/Sep/msg00454.html 
> <http://prod.lists.apple.com/archives/cocoa-dev/2015/Sep/msg00454.html>.
> I have a library, that provide developer-friendly interface to 
> AddressBook.framework. And I unable to use GCD for thread safety, because of 
> `ABAddressBookRegisterExternalChangeCallback` function, that requires a run 
> loop to schedule callback. 
> So I decided to use NSThread subclass. And found that second NSThread 
> instance blocks main thread on `start` method call.
> Here is the source code of Example - 
> https://www.dropbox.com/s/r5k8o28pocu7afk/aptest.zip?dl=0 
> <https://www.dropbox.com/s/r5k8o28pocu7afk/aptest.zip?dl=0>
> When you press 'load contacts' for the second time, it'll block main thread 
> with `semaphore_wait_trap`
> Any ideas?

Why are you using threads at all? If there is a run loop callback, that 
probably means you should schedule it on the run loop. Don’t introduce 
threading unless you are doing something in that callback that blocks the UI. 
Even then, schedule your callback on the UI run loop and have your callback 
spawn the thread or async block.

And that API is deprecated in iOS9 anyway. If you don’t need to support iOS 8 
or earlier, use the new Contacts API.

John Daniel

_______________________________________________

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