I will try to explain shortly what my problem is...
I'm loading an XML file (using touchXML) to populate a UITableView with data.
expositions = [[NSMutableArray alloc] init];
// Get XML string from XML document.
NSString *xmlURL = EXPOSITION_XML_DOC;
NSString *xmlString = [NSString stringWithContentsOfURL:[NSURL URLWithString:xmlURL]];
NSString *xmlStringUTF8 = [NSString stringWithUTF8String:[xmlString UTF8String]];
CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithXMLString:xmlStringUTF8 options:0 error:nil];
// Parse XML document.
NSArray *expos = [xmlDoc nodesForXPath:@"/expositions/exposition" error:nil];
if (expos != nil && [expos count] >= 1)
{
// create Exposition instances with data from xml file
for (CXMLElement *expo in expos)
{
NSString *date = [[[[expo attributeForName:@"date"] stringValue] copy] autorelease];
NSString *name = [[[[expo attributeForName:@"name"] stringValue] copy] autorelease];
NSString *place = [[[[expo attributeForName:@"place"] stringValue] copy] autorelease];
NSLog(@"hello , %@, %@, %@", date, name, place);
Exposition *e = [[Exposition alloc] initWithDate:date name:name place:place];
[expositions addObject:e];
NSLog(@"%@", e.name);
}
}
At the end of the for loop, you can see that output some of the data just passed and it works fine in NSLog returning the parsed XML data.
But when I try to access the array in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
like so...
// get exposition data for this row
Exposition *e = [expositions objectAtIndex:indexPath.row];
NSString *str = e.name;
NSLog(@"%@", str);
I get an error! And I don't understand why. I have some German umlauts in the parsed XML data but I defined the UTF-8 encoding so this should not be a problem. But if it is, please tell me a fix. Or whatever else could be the problem...