I have about 15 URLs for XML Parsing simultaneously. I am using KMXML Parser for XML parsing.
How can i do Parsing simultaneously using thread. How to handle the responses form that parsing. How can i store those responses in Sq-lite Database.
My code for parsing is as follow:
NSArray* yourURLs = [NSArray arrayWithObjects:@"http://www.designworldonline.com/rss/",@"http://www.3dcadtips.com/feed/",@"http://feeds.feedburner.com/MakePartsFast",@"http://www.designworldonline.com/category/technologies/electricalelectronic/feed", nil];
for(NSString* url in yourURLs) {
[self performSelectorInBackground:@selector(parse:) withObject:url];
}
-(void)parse:(NSString*)link {
KMXMLParser *parser = [[KMXMLParser alloc] initWithURL:link delegate:self];
_parseResults = [parser posts];
[self performSelectorOnMainThread:@selector(update) withObject:_parseResults waitUntilDone:NO];
}
-(void)update
{
[pd addObject:_parseResults];
}
But with this coding,
_parseresults=[parser posts]; is called only for last link rather than for each link.
and i got response in array pd is only from last link & 9 times. i don’t know why parsing method is only called last time only.
try to use framework will help you very will
https://github.com/AFNetworking/AFNetworking
https://github.com/pokeb/asi-http-request