Hey guys,
stack overflow has already helped me a lot during my programming work so at first: Thanks a lot for all the asked questions and the excellent answers.
Nevertheless I have a problem right now, for which I just couldn't find the right answer here.
I am programming a Iphone App which is supposed to parse a flat-file from the web, create managed objects from the flat-file and later on should display them in a UITableView. There are no problems with the saving and the displaying, but I just can't get the hang of a good Parser.
Thats the file I want to parse: Flat-file
AS far as I know, I can't use the NSXMLParser for this task (because obviously there are no tags).
So i at first tried to programm an NSScanner which should get me the interesting properties --> didn't work out
now I am using this method:
- (void) parseMemberDataWithURL: (NSString *)urlString
{
self.memberTempCounter = 1;
//Get data from web
self.downloadedText = [NSString stringWithContentsOfURL: [NSURL URLWithString: urlString] encoding:NSUTF8StringEncoding error:nil ];
memberArray = [downloadedText componentsSeparatedByString:@";"];
while (self.memberTempCounter<[memberArray count])
{
[[ExhibitorController sharedController] createExhibitorWithName:[memberArray objectAtIndex:self.memberTempCounter]
street:[memberArray objectAtIndex:self.memberTempCounter+2]
zip:[memberArray objectAtIndex:self.memberTempCounter+3]
city:[memberArray objectAtIndex:self.memberTempCounter+4]
email:[memberArray objectAtIndex:self.memberTempCounter+7]
phone:[memberArray objectAtIndex:self.memberTempCounter+5]
website:[memberArray objectAtIndex:self.memberTempCounter+8]
produktbereiche:[[memberArray objectAtIndex:self.memberTempCounter+9] componentsSeparatedByString:@","]];
self.memberTempCounter= self.memberTempCounter+13;
}
}
I am using the memberTempCounter to identify the property.
The problems are:
- This only works out in like 3 of 4 times. 1 of 4 times the App crashes and I have no Idea why....
- The method has a performance like a 1962 VW Beetle. Parsing the whole chunk of data takes up to 3 Minutes on my Iphone 3G
Any Ideas or a simpler way to do this?
I would be really gratefull. Thanks in advance :-)