我有方法dateFromString一个问题,这里是我的代码NSDateFormatter dateFromString与日期
NSString* res = [NSString stringWithFormat:@"%@/%@/%@",dateInput.text,monthInput.text,yearInput.text];
NSDateFormatter* formatter = [[NSDateFormatter alloc]init];
[formatter setTimeZone:[NSTimeZone localTimeZone]];
[formatter setDateFormat:@"dd/MM/yy"];
NSDate* inpTime = [formatter dateFromString:res];
[dateResult setText:[NSString stringWithFormat:@"%@",inpTime]];
当我运行,日期在“inpTime”始终是“dateInput” - 1 例如:如果“ dateInput“为5,”inpTime“中的日期为4
您的代码是完美的..没有错误!!!,请尝试清理目标。 –