My app keeps crashing on app load with the culprit being the line:
cell.textLabel.text = [[self.searchResults objectAtIndex:[indexPath row]] valueForKey:@"payment_frequency"];
The error I get is:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x8a538e0'
self.searchResults does have 4 objects in it as it is an array. Each object as the follows:
{
50316462547c6dbdf2000005 = {
"created_at" = "2012-08-19T17:10:42-0500";
id = 50316462547c6dbdf2000005;
"payment_frequency" = "One Time";
"user_id" = 1;
};
50316462547c6dbdf2000005 = {
"created_at" = "2012-08-19T17:10:42-0500";
id = 50316462547c6dbdf2000005;
"payment_frequency" = "One Time";
"user_id" = 1;
};
50316462547c6dbdf2000005 = {
"created_at" = "2012-08-19T17:10:42-0500";
id = 50316462547c6dbdf2000005;
"payment_frequency" = "One Time";
"user_id" = 1;
};
50316462547c6dbdf2000005 = {
"created_at" = "2012-08-19T17:10:42-0500";
id = 50316462547c6dbdf2000005;
"payment_frequency" = "One Time";
"user_id" = 1;
};
}
Here is the complete code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"SearchResultsViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[self.searchResults objectAtIndex:[indexPath row]] valueForKey:@"payment_frequency"];
return cell;
}
The error message tells you that your are sending objectAtIndex: to a dictionary object, not an array.
You have :
or