fredley
fredley

Reputation: 33901

EXC_BAD_ACCESS - How can I avoid it?

I have an asynchronous upload process. After it finishes, it pokes the main thread to update the UI.

    @try {
        if ([self respondsToSelector:@selector(updateUploadFinished)]) {
            [self performSelectorOnMainThread:@selector(updateUploadFinished) withObject:nil waitUntilDone:NO];
        }
    }
    @catch (NSException *exception) {
        NSLog(@"Failed to perform selector on main thread: %@",[exception reason]);
        return;
    }

The problem is if I move away from this view I get an EXC_BAD_ACCESS. I've tried to avoid it, as you can see in the code above, but it still crashes the app. How can I get around this?

Upvotes: 0

Views: 103

Answers (1)

Manish Agrawal
Manish Agrawal

Reputation: 11026

you have to remove the delegation of that asynchronous call on your viewWillDisappear.

Upvotes: 4

Related Questions