views:

27

answers:

1

I have an object which holds a title and an indexReference. I save the object to an array and that works correctly.

I then try to load from the array and populate the tableview.

I use this code.

//fill it with contents
SavedFav *temp = [tableViewData objectAtIndex:indexPath.row];
cell.textLabel.text = temp.title;  

I then get an error as the following

2010-07-01 15:42:46.386 Daily Quote[1308:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString title]: unrecognized selector sent to instance 0x23f6688'

What is causing this problem?

Thanks in advance.

+1  A: 

"temp" is a string obviously, so it's too many answers to give, either you filled tableViewData with strings and trying to obtain title from a string (which is unrecognized) or you have problem with memory there, without seeing more code it's hard to say. however try

cell.textLabel.text = temp;

and check what's inside, that will give you a good lead.

Alexander Voloshyn
No, temp is an object which has a NSString *title and an int indexReference. so I am trying to get the title from the object and assign it to the cell. that is where the error comes from.
alJaree
temp is a pointer, it points to the class instance and it can be any class instance theoretically, in concrete case it's string for sure. You need to figure out why it is string and not your object which contains string title. For that try cell.textLabel.text = temp; and tell what you see in the cell.
Alexander Voloshyn
No, `temp` is an NSString. You may *intend* for it to be your object, but it's an NSString. You can tell by the `-[NSCFString title]` in the error text. You're sending the `-title` message to `temp` (in your code as `temp.title`), but `temp` is actually an NSString. This means two things: 1) follow Alexander Voloshyn's instructions to find out what's in `temp` and 2) you have a bug elsewhere in your code that is adding strings to your array when it should be adding your object.
CajunLuke
I just see the tableView blank, the cell is blank if I use cell.textLabel.text = temp;I will post the code which adds the object to the array as an answer here for reading clarity.
alJaree
could it not be this line of code SavedFav *temp = [tableViewData objectAtIndex:indexPath.row]; is assigning something different to temp. ?
alJaree