Reputation: 3127
is it possible to detect disk operations on main thread? ie queries to sqlite executed on main thread. In android there is Strict mode which will crash application every time when app does disk operation on main thread but. Is there something like this in ios?
I have inherited big codebase and randomly discovered database queries executing on main thread. I would like to have some option to simply discover all. (I used instruments but something like throwing exception every time there is unallowed operation on main thread will be better)
Only possible solution which I see is to check Thread.current.isMainThread before every disk operation
Thanks
Upvotes: 0
Views: 275
Reputation: 19750
You can enable Core data concurrency debug mode which is like a Strict mode, it will throw an exception when core data entities are accessed from an incorrect thread.
You can enable it by passing the following argument when running
-com.apple.CoreData.ConcurrencyDebug 1
You can get more information and a more in-depth explanation here
Upvotes: 1