Why is UIImage's drawAtPoint throwing an error in this code?
<p>I am creating custom cell in my iphone aap and I am also adding an image to it but I continue to get error at [image drawatpoint:p];</p>

<p>the error states
*** -[UIImage drawAtPoint:]: message sent to deallocated instance 0x45cb1f0</p>

<p>my code is</p>

<pre><code>-(void)setImage:(UIImage *)i
{
    //[image release];
    image = i;
    [self setNeedsDisplay]; 
}

- (void)setNeedsDisplay
{
    [super setNeedsDisplay];
    [contentView setNeedsDisplay];
}

- (void)drawContentView:(CGRect)r
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    UIColor *backgroundColor = [UIColor yellowColor];
    UIColor *textColor = [UIColor blackColor];

    if(self.selected)
    {
     backgroundColor = [UIColor clearColor];
     textColor = [UIColor whiteColor];
    }

    [backgroundColor set];
    CGContextFillRect(context, r);

    CGPoint p;
    p.x = 3;
    p.y = 3;

    [textColor set];
    UIImage *image2 = image;
    [image2 drawAtPoint:p];

    p.x += 70; // space between words
    [text2 drawAtPoint:p withFont:firstTextFont];

    //[image release];
}
</code></pre>
