views:

56

answers:

2

I get a crash with this console message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFArray row]: unrecognized selector sent to instance 0x3953a20'

This happens when I scroll trough a table that gets its data from an array of dictionaries.

A: 

Looks like you are sending a row message to an NSArray. There is no row method defined in the NSArray class. If you are using a table, my guess is you want to send "row" to the indexPath parameter to get the position and then get the data at that position in your data array:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // first row will be like 0
    NSUInteger row = [indexPath row];
    // get the same row position in your data array
    id data = [YOUR_DATA_ARRAY objectAtIndex:row];
}

That will give you the numeric position of the row. One caveat: "row" is not part of the base NSIndexPath class. It's added as a category in UIKit.

Typeoneerror
+2  A: 

Look in the crash log's stack trace to see where exactly this call is happening.

If the variable you're sending -row to isn't actually typed as an NSArray, it's likely that you've failed to follow the memory management rules for that variable. These same symptoms are very commonly caused by that. Something that responds to -row could have existed at one point, been deallocated because you didn't -retain it, and then an NSArray was later allocated in that spot.

Run a "Build & Analyze," and re-re-review the memory management guidelines until you know them in your sleep.

bdrister
The problem was that a variable named 'row' was somehow being deallocated.
Nick Dima