views:

29

answers:

1

I have a program which works normally. Then I downloaded some code from http://github.com/matej/MBProgressHUD to show a progress meter when doing something.

This is the code that makes the progress meter pop up.

[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

This will show a progress meter while the method myTask is running.

This is the code for the showWhileExecuting method.

- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {

    methodForExecution = method;
    targetForExecution = [target retain];
    objectForExecution = [object retain];

    // Launch execution in new thread
 taskInProgress = YES;
    [NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil];

 // Show HUD view
 [self show:animated];
}

If I use this to call the function myTask then one of my class properties will change from an NSMutableString to an NSData object somewhere, and then later on it will change to an NSString. I don't see anywhere in the code that causes this to change, so it's probably some kind of bug. Is memory getting corrupted? What's causing this to happen?

+3  A: 

Most likely it's a memory (retain/release issue). If you don't properly retain an object, it may get released out from under you. At that point, the memory will be reclaimed by the OS, which may decide to store something else there. Try turning on NSZombies, and double checking your retain/release/autoreleases.

Ben Gottlieb
When I turn on NSZombies, I can see that the object turns into an NSZombie NSArray.
awakeFromNib