Would the code bellow cause my code to leak? More specifically, am I responsible for releasing the newImage
or the contents of mainPageLayer
(which is a CALayer
object)? I get a memory warning every 4th time that method is called, but cant figure out why...
I also can't figure out why mainPageLayer.contents = [newImage CGImage];
t开发者_Go百科hrows a warning that the argument I am passing is of an incompatible pointer time. The image shows up just fine inside the layer.
-(void)setPrimaryPage:(UIImage *)newImage {
pImageSizeWidth = newImage.size.width;
pImageSizeHeight = newImage.size.height;
[mainPageLayer setFrame:CGRectMake(0, 0, pImageSizeWidth, pImageSizeHeight)];
mainPageLayer.contents = [newImage CGImage];
}
the contents property is defined as follows:
@property(retain) id contents
which means that the CGImageRef
from newImage
is retained. Whether your code leaks isn't clear from your code: There's not enough context. It will only leak if newImage
was retained upon calling your setPrimaryPage:
.
精彩评论