Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronizing NSMutableArray for Thread Security ?

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 ...

like image 756
Ansari Avatar asked Aug 19 '10 11:08

Ansari


1 Answers

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

@synchronized(myArray) {
  [myArray doSomething];
}
like image 109
Claus Broch Avatar answered Oct 21 '22 13:10

Claus Broch