Reputation: 6386
NSDateFormatter *formatter;
NSString *dateString;
formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-MM-yyyy HH:mm a"];
dateString = [formatter stringFromDate:[NSDate date]];
[formatter release];
appDelegate.myCallLogDict = [[NSMutableDictionary alloc]init];
[appDelegate.myCallLogDict setObject:phoneNo forKey:@"CallLogPhoneNoKey"];
[appDelegate.myCallLogDict setObject:dateString forKey:@"CallLogTimeStampKey"];
I have stored phone no and time into an nsmutabledictionery and i want to access that dictionery value as like below into the -
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method
cell.detailTextLabel.text = [[appDelegate.myCallLogDict objectForKey:@"CallLogTimeStampKey" ]objectAtIndex:row];
cell.textLabel.text = [[appDelegate.myCallLogDict objectForKey:@"CallLogPhoneNoKey"] objectAtIndex:row];
when i run the above code i get the below error
Please help me up
-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5b227e0
2011-12-15 10:06:09.050 MyDialer[1090:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5b227e0'
Thanks a lot for your help
Upvotes: 0
Views: 4029
Reputation: 51
In my case there was the following problem:
@property (nonatomic, retain) NSIndexPath *selectedCell;
@synthesize selectedCell = _selectedCell;
with a getter
and then some where in the code the call self.selectedCell.row caused crash
After getter has been changed to
a bug disappeared. The bug has been noticed on iOS 5 only.
Upvotes: 1
Reputation: 19418
try this :
cell.detailTextLabel.text = [appDelegate.myCallLogDict objectForKey:@"CallLogTimeStampKey"];
cell.textLabel.text = [appDelegate.myCallLogDict objectForKey:@"CallLogPhoneNoKey"];
you don't need to use objectAtIndex as you are getting single string by
[appDelegate.myCallLogDict objectForKey:@"CallLogPhoneNoKey"];
Upvotes: 3
Reputation: 4254
I think you have to save your key data in an array and then use the objectAtIndex
on that array.
Upvotes: 1
Reputation: 9132
You are expecting your dictionary to contain an array of strings for the key CallLogTimeStampKey, but you inserted just a single string.
Upvotes: 1