Problem: an error message is displayed when a member variable is used.
Problem: I want to implement a tree structure of uitableview, and then re-derive the uitableviewcell and add the treenode node to it. Code As follows:
@ Interface treeviewcell: uitableviewcell {
Treenode * treenode; // each cell represents a node.
}
@ Property (retain) treenode * treenode;
@ Implementation treeviewcell @ Synthesize onexpand, imgicon, owner, treenode;
Then I use treenode of treeviewcell in another view, as shown below:
Uitableviewcell * cell = [self. tableview cellforrowatindexpath: indexpath]; [Cell onexpandcell]; Treenode * treenode = cell. treenode;
The following error is prompted in the line treenode * treenode = cell. Tree: Request for member 'treenode' in something not a structure or union
|
The solution to this problem is:
Treeviewcell * cell = (treeviewcell *) [self. tableview cellforrowatindexpath: indexpath]; Treenode * treenode = cell. treenode; |
Method 2: To determine whether a node has a subnode, you can add a method to the treenode and obtain the value using the uitableviewcell attribute.
You can also use the method to return a bool type value and then make a judgment.