Incorrect decrement of the reference count
Posted
by idober
on Stack Overflow
See other posts from Stack Overflow
or by idober
Published on 2010-06-07T22:04:55Z
Indexed on
2010/06/07
22:12 UTC
Read the original article
Hit count: 450
objective-c
I have the following problem: In one flow of the execution I use alloc, and on the other flow, alloc is not needed. At the end of the if statement, in any case, I release the object. When I do 'build and Analize' I get an error: 'Incorrect decrement of the reference count of an object is not owned by the caller'.
How to solve that?
UIImage *image;
int RandomIndex = arc4random() % 10;
if (RandomIndex<5)
{
image = [[UIImage alloc] initWithContentsOfFile:@"dd"];
}
else
{
image = [UIImage imageNamed:@"dd"];
}
UIImageView *imageLabel =[[UIImageView alloc] initWithImage:image];
[image release];
[imageLabel release];
© Stack Overflow or respective owner