Hi!
First of all: I've got NSZombieEnabled.
I am loading XML data into a UITableView in a seperate thread because I want to display an UIActivityIndicator as the XML data is loading.
In my viewDidLoad I call performSelectorInBackground as well as adding the loading indicator:
- (void)viewDidLoad {
[super viewDidLoad];
loadingIndicator = [[[UIActivityIndicatorView alloc] init]autorelease];
loadingIndicator.frame = CGRectMake(140, 190, 37, 37);
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[loadingIndicator startAnimating];
[self.view addSubview:loadingIndicator];
[self performSelectorInBackground:@selector(getEvents) withObject:nil];
buttonBack.backgroundColor = [UIColor clearColor];
UIImage* bgImage = [UIImage imageNamed:@"Background.png"];
self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage: bgImage] autorelease];
}
In my getEvents method I also set up my UITableView using performSelectorOnMainThread:
-(void) getEvents {
NSAutoreleasePool *poool = [[NSAutoreleasePool alloc] init];
NSURL *xmlUrl = [[[NSURL alloc] initWithString:@"http://www.xml.xml"] autorelease];
NSString *converted = [[[NSString alloc] initWithContentsOfURL:xmlUrl encoding:NSISOLatin1StringEncoding error:nil] autorelease];
TBXML *XMLObject = [[TBXML tbxmlWithXMLString:converted] retain];
TBXMLElement *rootXMLElement = XMLObject.rootXMLElement;
TBXMLElement *post = [TBXML childElementNamed:@"event" parentElement:rootXMLElement];
arrayEvents = [[NSMutableArray alloc] init];
while (post != nil)
{
TBXMLElement *title = [TBXML childElementNamed:@"title" parentElement:post];
NSString *titleText = [TBXML textForElement:title];
currentEvent = [[Event alloc] init];
currentEvent.title = titleText;
[arrayEvents addObject:currentEvent];
post = [TBXML nextSiblingNamed:@"event" searchFromElement:post];
}
[self stoppedLoadingEvents];
[self performSelectorOnMainThread:@selector(createTableView) withObject:nil waitUntilDone:YES];
[poool release];
}
Then at last I set up the tableView and do som releasing on the Actitity Indicator:
- (void) createTableView {
tableEvents = [[UITableView alloc] initWithFrame:CGRectMake (0, 70, 320, 350) style:UITableViewStylePlain];
tableEvents.delegate = self;
tableEvents.dataSource = self;
tableEvents.backgroundColor = [UIColor clearColor];
tableEvents.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:tableEvents];
}
- (void) stoppedLoadingEvents{
[loadingLabel setHidden:YES];
[loadingIndicator setHidden:YES];
[loadingIndicator stopAnimating];
[loadingIndicator release];
}
This works perfectly fine until I start to scroll my tableView up and down. For every motion with the mouse up and down the Console just spamming me with hundreds of messages, all with the same text:
modifying layer that is being finalized
I've never recieved a message like that.
When I press a tableViewCell I receive:
-[CALayer retain]: message sent to deallocated instance 0x808cfa0
I think that all of this has to do with threading and NSAutoReleasePools because none of this happened before I decided to put the getEvents method in a seperate thread to be able to show the UIActivityIndicator as the XML was loading.
Please swing me in the right direction!