Synchronizing NSMutableArray for Thread Security ?

烈酒焚心 提交于 2019-11-27 12:28:52

问题


I have a Threaded application, in which there is a NSMutableArray, which contains the NSManagedObjects, Now i want my array to be accessed once at a time by any Thread. So how do i synchronize that array, or may be put locking mechanism on it.

Thanks in Advance ...


回答1:


You could wrap every access to the class with something like the following:

@synchronized(myArray) {
  [myArray doSomething];
}


来源:https://stackoverflow.com/questions/3521190/synchronizing-nsmutablearray-for-thread-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!