Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems populating UITableView with data from XML file
    primarykey
    data
    text
    <p>I will try to explain shortly what my problem is... </p> <p>I'm loading an XML file (using touchXML) to populate a UITableView with data.</p> <pre><code>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 &amp;&amp; [expos count] &gt;= 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); } } </code></pre> <p>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.</p> <p>But when I try to access the array in</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath </code></pre> <p>like so...</p> <pre><code>// get exposition data for this row Exposition *e = [expositions objectAtIndex:indexPath.row]; NSString *str = e.name; NSLog(@"%@", str); </code></pre> <p>I get an error! And I don't understand why. I have some German <a href="http://en.wikipedia.org/wiki/Germanic_umlaut" rel="nofollow noreferrer">umlauts</a> 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...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload