Hi guys,
i'm having a bad time with some little code running on the iphone
basically, i just press a button, it calls runTest
, it runs test
method on a background thread. That's why I created an autorelease pool.
if i run the below code i got a beautiful message on the console saying:
2010-09-07 11:45:15.527 test[1312:207] *** -[CFString release]: message sent to deallocated instance 0x3d52ba0
-(void) test {
NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];
NSString *xml = [[NSString alloc] initWithFormat:@"<%@>", @"msg"];
NSLog(@"%@\n",xml);
[xml release];
[apool release]; // <-- this line throws the error msg
}
- (IBAction) runTest: (id)sender
{
[self performSelectorInBackground:@selector(test) withObject:nil];
}
i have found that: if i do not run test
on a background thread (no autorelease pool), just calling [self test]
, the code works fine.
so, i think the problem is around the thread + autorelease pool, what am I doing wrong? and how may i solve it?
thanks!!
pd. i have the NSZombie flag enabled