I am unsuccessfully trying to populate a UITable from a NSMutableArray that contains a custom object.
My Student object
Student {
NSString name,
int age
}
In my UITableView’s controller I have implemented a method that displays the row’s content:
cellForRowAtIndexPath
{
// there is more code here
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
}
But the above does not work for an object inside an array.
Should my Student class implement a method that returns a String representation of the object? And then how can I display the content of the NSMutableArray in the UITableView.
Any help will be appreciated.
Your objectAtIndex should be a Student object, so you need to get its properties — assuming that name and age are properties, you should be able to reference them with [(Student *)[tableData objectAtIndex:indexPath.row] name]; and the corresponding one for age.