IPhone request for member 'treenode' in something not a structure or uni

Source: Internet
Author: User

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.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.