mistakenly use of NSPrivateQueueConcurrencyType #76

Closed
simpzan opened this Issue Jul 11, 2012 · 2 comments

Comments

Projects
None yet
3 participants

simpzan commented Jul 11, 2012

http://stackoverflow.com/questions/11436358/nsprivatequeueconcurrencytype-context-can-only-operate-within-performblock

when creating -managedObjectContext of XMPPCoreDataStorage. NSPrivateQueueConcurrencyType type is not correct here. NSPrivateQueueConcurrencyType context can only used with -performBlock...
the old NSConfinementConcurrencyType is appropriate for your code.
check up the doc: http://developer.apple.com/library/mac/#releasenotes/DataManagement/RN-CoreData/_index.html

the following is quoted from apple doc: http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iOS5.html

"When sending messages to a context created with a queue association, you must use the performBlock: or performBlockAndWait: method if your code is not already executing on that queue (for the main queue type) or within the scope of a performBlock... invocation (for the private queue type). Within the blocks passed to those methods, you can use the methods of NSManagedObjectContext freely. "

Owner

robbiehanson commented Aug 1, 2012

Thanks for pointing this out to me.

You know, even after reading the documentation I'm still a bit confused. From what I understand (correct me if I'm wrong), the NSPrivateQueueConcurrencyType creates it's own private/internal queue. And we're supposed to then only access the context via performBlock: or performBlockAndWait:. But for some odd reason (IMO), it doesn't bother to enforce this rule?

At any rate, it sounds like you're absolutely correct. NSConfinementConcurrencyType is appropriate.

@davidchiles davidchiles pushed a commit to davidchiles/XMPPFramework that referenced this issue Jan 26, 2016

@robbiehanson robbiehanson Bug fix for issue #76 - mistaken use of NSPrivateQueueConcurrencyType 5bef245

idoza commented Apr 3, 2016

NSConfinementConcurrencyType is first deprecated on iOS 9.
How can we replace it considering this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment