当我点击一行时,我的应用程序冻结,这是didSelectRowAtIndexPath的代码,stringDate等于这样的字符串: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];

在带有此错误的NSString *stringDate = [cellValue valueForKey:@"date"];行上点击该行时,出现此错误:

*由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无效的参数不令人满意:日期”

更新:使用日期和时间模式将解析的日期设置为UIDatePicker,我只是将字符串日期转换为NSDate以便与[timePicker setDate:savedDate animated:YES];一起使用

我创建了cellValue作为NSDictionary,它基本上访问了plist,在其中创建了NSDictionary,然后使用格式化的NSString对其进行了编写。 array显示plist数组,因此我可以使用[cellValue objectForKey:@"date"]访问它
NSDictionary *cellValue = [self.array objectAtIndex:[indexPath row]];

最佳答案

您需要教格式化程序您的字符串满足的格式

应该是这样的:

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMM d"];

10-07 18:18