iPhone: One Object, One Thread
- by GingerBreadMane
On the iPhone, I would like to do some operations on an image in a separate thread. Rather than dealing with semiphores, locking, etc., I'd like to use the 'One Object, One Thread' method of safely writing this concurrent operation. I'm not sure what is the correct way to copy my object into a new thread so that the object is not accessed in the main thread. Do I use the 'copy' method? If so, do I do this before the thread or inside the thread?
...
-(void)someMethod{
UIImage *myImage;
[NSThread detachNewThreadSelector:@selector(getRotatedImage:) toTarget:self withObject:myImage];
}
-(void)getRotatedImage:(UIImage *)image{
...
...
UIImage *copiedImage = [image copy];
...
...
}