iPhone: One Object, One Thread
Posted
by GingerBreadMane
on Stack Overflow
See other posts from Stack Overflow
or by GingerBreadMane
Published on 2010-03-12T02:47:05Z
Indexed on
2010/03/12
2:47 UTC
Read the original article
Hit count: 259
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];
...
...
}
© Stack Overflow or respective owner