gpt4 book ai didi

objective-c - 无效参数不满足 : date

转载 作者:行者123 更新时间:2023-12-02 07:06:27 24 4
gpt4 key购买 nike

我遇到了来自 Crashlytics 的问题。我有调试参数,所以我看到有哪些参数。

datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 0, 0)];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *startTimeString = [MathFunctions minutesToTimeString:[appointment.start_time integerValue]];
NSLog(@"Time: %@",startTimeString);
NSLog(@"Date: %@", appointment.date);
[dateFormatter setDateFormat:@"yyyyMMdd h:mm a"];
[Crashlytics setObjectValue:[NSString stringWithFormat:@"%@ %@", appointment.date, startTimeString] forKey:@"ResAddDate"];
NSString *dateTimeString = [NSString stringWithFormat:@"%@ %@", appointment.date, startTimeString];
NSLog(@"Date String: %@", dateTimeString);
datePicker.date = [dateFormatter dateFromString:dateTimeString];

来自 crashlytics 的崩溃日志显示日期格式正确

重新添加:20120621 12:00 AM

崩溃发生在 datePicker.date = [dateFormatter dateFromString:dateTimeString];

如果日期格式存在且正确,为什么会崩溃?

Crashlytics 日志:

CoreFoundation  
__exceptionPreprocess + 162
1 libobjc.A.dylib
objc_exception_throw + 32
2 CoreFoundation
+[NSException raise:format:]
3 Foundation
-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 90
4 UIKit
-[UIDatePickerView _updateBitsForDate:forced:andReload:animateIfNeeded:] + 146
5 UIKit
-[UIDatePickerView _setDate:animated:forced:] + 348
6 UIKit
-[UIDatePickerView setDate:animated:] + 30
7 UIKit
-[UIDatePicker setDate:] + 36
8 MyApp ReserveAddController.m line 283
-[ReserveAddController showDatePicker] + 283
9 MyApp ReserveAddController.m line 179
-[ReserveAddController tableView:didSelectRowAtIndexPath:] + 179
10 UIKit
-[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 944
11 UIKit
-[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 158
12
Foundation
__NSFireDelayedPerform + 414
13 CoreFoundation
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
14 CoreFoundation
__CFRunLoopDoTimer + 364
15 CoreFoundation
__CFRunLoopRun + 1206
16 CoreFoundation
CFRunLoopRunSpecific + 300
17 CoreFoundation
CFRunLoopRunInMode + 104
18 GraphicsServices
GSEventRunModal + 136
19 UIKit
UIApplicationMain + 1080
20 Appointment-Plus main.m line 16
main + 16
21 Appointment-Plus

最佳答案

请注意,您可能会被语言环境“feechure”所困扰。您需要设置 NSDateFormatter 的语言环境。

使用美国语言环境设置手机,然后将 12/24 设置设置为 24。同时设置欧洲语言环境手机,然后将 12/24 设置设置为 12。可能一个或另一个或两个都会失败。

关于objective-c - 无效参数不满足 : date,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11129698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com