Parsing works great.
-(void) callParse
{
parser = [[NSXMLParser alloc] initWithData:data];
parser.delegate = self;
[parser parse];
[parser release];
}
I want to perform parsing in background. This code doesn't do any parsing. But why?
@interface NSXMLParser(Private)
- (void)myParse;
@end
@implementation NSXMLParser(Private)
- (void)myParse
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self parse];
[pool drain];
}
@end
-(void) callParse2
{
parser = [[NSXMLParser alloc] initWithData:data];
parser.delegate = self;
[NSThread detachNewThreadSelector:@selector(myParse) toTarget:parser withObject:nil];
[parser release];
}
UPDATE: I call callParse2 4 times and it creates 4 threads. It does some parsing but the results is messy. May be I have some problem with synchronization variables. NSXMLParser calls delegates which uses nonatomic properties.