I have made a custom object called students that has two nsstring object. One is for the name and the other for the student id. If I try to pass the custo开发者_如何学Gom object to something that takes nsstring, it doesn't work. I want to pass the name. How can I do this?
You can nest your method calls like this:
cell.textLabel.text = [[studentArray objectAtIndex:indexPath.row] name];
Or if you defined your members as properties and want to access them via dot-notation:
cell.textLabel.text = [studentArray objectAtIndex:indexPath.row].name;
The only issue with the dot-notation approach is the compiler will most likely give you warning that it couldn't find the property name
, so you will need to cast it to the appropriate data type before accessing the property via dot-notation.
精彩评论