I have an array gathered by componentsSeparatedByString: that looks like the following when I use po in the GDB after the array has gone through componentsSeparatedByString:
"\n\t\t <b>Suburb,
</b> BAIRNSDALE",
"\n\t\t <b>Address,
</b> 15K NW BAIRNSDALE",
"\n\t\t <b>Reference,
</b> MELWOOD/SCHOOL ROAD",
"\n\t\t <b>Last Changed,
</b> 09/04/10 05,
29,
00 PM",
"\n\t\t <b>Type,
</b> HOME",
"\n\t\t <b>Status,
</b> BUILT",
"\n\t\t <b>Property Size,
</b> 2.00 HA.",
"\n\t\t <b>Residents,
</b> 2",
"\n\t\t <b>First Added Date/Time,
</b> 09/04/10 03,
15,
00 PM",
"\n\t\t\t"
Only problem is, I now can't figure out where to go from here. I need to be able to access each of these items (i.e. type, status, property size) separately rather than just calling the entire array (i.e. currentProperty.status). How do I do this?
Also what's with all the n\t\t\t things - how do I get rid of them?
Update: For a similar type of feed, see here - this was for another project, but I never solved it. The string I'm parsing is referred to as "description" in the other project, but开发者_如何学编程 is formatted exactly the same way just with different info.
And here's the code using the componentsSeperatedByString
NSString *string = [parser currentString];
NSArray *strings = [string componentsSeparatedByString: @"<br>"];
NSString *myArrayString = [strings description];
NSString *finalstring = myArrayString;
NSArray *finalstrings = [finalstring componentsSeparatedByString: @":"];
NSString *finalArrayString = [finalstrings description];
parser.currentProperty.description = finalArrayString;
Thanks.
Couple of things instantly jump out...
First off, the data looks to be markup. There will be a much better way of parsing this. Could you post the markup you're trying to parse, and also the state the string you're passing into componentsSeparatedByString:
As for the \n\t\t... etc, these are formmating characters... \n is a new line, for example. You'll get rid of them by adopting a better approach to parsing the data.
精彩评论