views:

132

answers:

1

I have enabled NSZombie's and I am getting the following message in my console when I am running my application:

 *** -[UIViewAnimationState release]: message sent to deallocated instance 0xf96d7e0

Here is the method that is performing the animation

-(void)loadAvatar:(STObject*)st
{   
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];    

    avatar.alpha = 0;
    avatar.frame = avatarRectSmall;

    avatar.image = [ImageCache getMemoryCachedImageAtUrl:st.avatar_url];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.50];

    avatar.frame = avatarRectNormal;
    [avatar setAlpha:1];
    [UIView commitAnimations];


    [pool release];
    pool = nil;
}

I don't always get a crash, only sometimes. I'm wondering what is getting released?

+2  A: 

You have an autorelease pool there which prompts me to ask, is this a separate thread? If the answer is yes then you can't do stuff to UIView there. UIKit is not thread safe. You can do other things like calculating positions or updating images which you later put on the screen but any user interface stuff has to happen in the main thread.

Graphics and Drawing section of iPhone Application Programming Guide

Adam Eberbach
You are correct, this is a separate thread. I just want to load an image from a URL in my UIImageView. If I remove the animation code, it will only load the images sometimes.
Sheehan Alam
Do you specifically need a separate thread for loading an image from a URL? Why not just use an async NSURLConnection or some other class with a delegate pattern?
Rengers