I am using an NSMutable Array as a datasource to UITableView. I am fetching the values from database and adding it to mutable array. When the view loads I populate the table view with the mutable array and it loads fine. Later when I click a cell it throws an error saying unrecognised selector sent to instance
Inside array I am storing a person object with a name property. I am loading all cells with person.name Later when I try to disolay person.name as the user clicks each cell it shows error.
This is how I do
Person *per = (Person*)[my arr objectAtIndex:indexPath.row];
NSlog(@"%@",per.name);
Here it crashes. But I am using the same code inside cellforRowAtIndexPath for displaying the person name.
Sometimes the error says Unrecognised selector name sent to NSArray
again sometime it says Unrecognised selector name sent to
UIDeviceRGBColor
So it means I am not getting correct object back from my NSMutable Array
How can I do this properly?
Thanks
This is due to the array is dealloacated. Make sure that the array is retained properly. In ARC have a strong reference. In non-ARC make sure you retain the array (I recommend to use property).