views:

46

answers:

1

Hello everybody,

I've got a tableview. In the "ViewDidLoad" method I have filled an array with CXMLElements. On debugging, I have seen that these are all CXMLNodes.

CXMLElement has a property to get the subelements which is called "elementsForName".

In the "cellForRowAtIndexPath:" method I used this property:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...

NSString *cellValue = [[[[self.tableDataSource objectAtIndex:indexPath.row] elementsForName:@"text"] objectAtIndex:0] stringValue];
[[cell textLabel] setText:cellValue];

...
}

It worked fine! But in the "didSelectRowAtIndexPath:" method I also want to use this property which damages my App:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
NSString *cellValue = [[[[self.tableDataSource objectAtIndex:indexPath.row] elementsForName:@"text"] objectAtIndex:0] stringValue];
NSLog(@"TEST: %@",cellValue);
...
}

There is no warning from the compiler. On selecting a row, the app breaks down.

I need your help.

Thanks

A: 

Thanks for your reply. I have tried it this way:

CXMLElement *Object1 = [self.tableDataSource objectAtIndex:indexPath.row];
NSArray *myArray = [Object1 elementsForName:@"text"];
CXMLNode *Object2 = [myArray objectAtIndex:0];
NSString *myName = [Object2 name];

I set a breakpoint a the first posted line and stepped over. When I was stepping in 4th line the apps hangs up. A watched all 4 expressions. The Array is empty. I added the screenshot here: http://img842.imageshack.us/img842/540/screenshoty.png

Here is my XML-File:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<navigation>
 <item id="i0000" src="content/i0000.xml" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[Welcome]]></text>
 </item>
 <item id="k1000" src="" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[WBT]]></text>
  <item id="k1010" src="" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[Chapter 1.1]]></text>
   <item id="i1011" src="content/i1011.xml" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[Infopage]]></text>
   </item>
  </item>
  <item id="k1100" src="" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[Chapter 1.2]]></text>
   <item id="i1101" src="content/i1101.xml" version="" active="1" visible="1" pagetype="" next="" properties=""><text><![CDATA[Subpage]]></text>
   </item>
  </item>
 </item>
</navigation>

at the beginning, my tableDataSource contains the first level of items (Welcome, WBT). I clicked on the second element which has subElements. Then I want to get all elements named "text" with this Element and so on.

Any Idea?? :-(

Vivid