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 custom object to something that takes nsstring, it doesn't work. I want to pass the name. How can I do this?
+1
A:
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.
Jacob Relkin
2010-09-17 08:01:31