i got an object and in that object i start my thread (for loading doing some url loading)
when i have a return of my data i call a selector to perform on the main thread.
works fine if i call it the first time , second time it crashes ( no specific error)
[NSThread detachNewThreadSelector:@selector(doThread:)
toTarget:self
withObject:@"lala"];
-(void) doThread:(NSString *)poststring {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DataModelLocator *mydelegate = [DataModelLocator instance];
NSData *postData = [poststring dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSURL *url = [NSURL URLWithString:[mydelegate fwaservicepath]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPBody:postData];
NSURLResponse *urlResponse;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:nil];
if(data) {
[self performSelectorOnMainThread:@selector(loadDidFinishWithData:)
withObject:data
waitUntilDone:YES];
//[self loadDidFinishWithData:data];
} else {
[self performSelectorOnMainThread:@selector(loadDidFinishWithError:)
withObject:data
waitUntilDone:YES];
}
[pool release];
} }
It crashes when i call the performSelectorOnMaintThread.. could it be that i it crashes on an singleton, when it got released?