IPhone: one object, one theme

On the iPhone, I would like to do some operations on the image in a separate stream. Instead of dealing with half-holes, locking, etc., I would like to use the "One Object, One Thread" method, which safely records this parallel operation. I'm not sure if this is the right way to copy my object to a new stream so that the object is not available in the main stream. Use the copy method? If so, am I doing this before the stream or inside the stream?

     ...
    -(void)someMethod{
        UIImage *myImage;
        [NSThread detachNewThreadSelector:@selector(getRotatedImage:) toTarget:self withObject:myImage];

    }

    -(void)getRotatedImage:(UIImage *)image{
        ...
        ...
        UIImage *copiedImage = [image copy];
        ...
        ...
    }
+3
source share
2 answers

, .

enter scope
    create object
    pass the object to the processing thread
    start the processing thread
exist scope
// the object is no longer visible/used/referenced

: , , , , , ... , . , .

Update:
... - , getRotatedImage, . . , , , .

+4

, - - , - , .

.

+5

Source: https://habr.com/ru/post/1736595/


All Articles