Reputation: 774
My app freezes when I tap a row, here is the code for didSelectRowAtIndexPath
, the stringDate
is equal to a string like this: Feb 4
.
EditView *editController = [[EditView alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:editController animated:YES];
NSDictionary *cellValue = [self.array objectAtIndex:[indexPath row]];
editController.savedString = [cellValue objectForKey:@"label"];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSString *stringDate = [cellValue valueForKey:@"date"];
NSDate *parsedDate = [df dateFromString:stringDate];
editController.savedDate = parsedDate;
[editController release];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
I get this error when tapping the row, on the line NSString *stringDate = [cellValue valueForKey:@"date"];
with this error:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: date'
UPDATE: The parsed date is set to a UIDatePicker
with date & time mode, and I am simply converting the string date to a NSDate
to be used with [timePicker setDate:savedDate animated:YES];
I created cellValue
as a NSDictionary
which basically accesses a plist
where I created a NSDictionary
and then wrote it with a formatted NSString
. And array
displays the plist
array, so I can access it using [cellValue objectForKey:@"date"]
NSDictionary *cellValue = [self.array objectAtIndex:[indexPath row]];
Upvotes: 2
Views: 168
Reputation: 52227
You need to teach the formatter the format your string fulfills
It should be something like:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMM d"];
Upvotes: 3