奇怪的 Xcode 行为
Strange Xcode behaviour
我打算将此作为苹果支持的错误提出,但需要很长时间才能得到他们的任何回复,所以...我想在这里问一下。
调试我在时区之间使用一些日期时间转换的应用程序。
我遇到了以下奇怪的行为,我想知道是否有其他人看到并知道如何解决它。
Xcode 8.3.2
您可以看到 GMTDate 显示了 2 个完全不同的 date/time 值(它们甚至不是相关值)并且很难知道哪个是正确的。
我重启了Xcode /computer等,还是一样!
附上截图:
- (NSString*) convertToDeviceTime:(NSString*) GMTDate {
//create the formatter for parsing
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//parsing the string and converting it to NSDate
NSDate *myGMTDate = [df dateFromString: GMTDate];
//create the formatter for the output
NSDateFormatter *out_df = [[NSDateFormatter alloc] init];
[df setTimeZone:[NSTimeZone systemTimeZone]];
[out_df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//output the date
NSString *myDeviceDate =[out_df stringFromDate:myGMTDate];
NSLog(@"the date is %@",myDeviceDate);
return myDeviceDate;
}
下面的新截图 - 这一定是 Xcode 有问题,
'token' 的实际值显示在快速查看中,但调试器 window 将其显示为日期!诡异的。我重启了Mac,还是一样
更新:所有 NSString 变量都会发生这种情况。只要我向它们写入一个值,调试器 window 就会向它们显示相同的日期值。如果我将它们打印到控制台或 NSLog,那么这些值就会正确显示。
找到罪魁祸首。
在调试器的 "Edit Summary Format" 弹出窗口中,我不知何故无意中粘贴了这个日期值,它显示了所有 NSString 值。
仅供参考:它不是特定于项目的,所以当我加载另一个项目时,它保留了 "Edit Summary Format" 字符串并将其应用于所有 NSString。
在此向较旧的 SO post 致敬:
附上截图!
我打算将此作为苹果支持的错误提出,但需要很长时间才能得到他们的任何回复,所以...我想在这里问一下。
调试我在时区之间使用一些日期时间转换的应用程序。 我遇到了以下奇怪的行为,我想知道是否有其他人看到并知道如何解决它。
Xcode 8.3.2
您可以看到 GMTDate 显示了 2 个完全不同的 date/time 值(它们甚至不是相关值)并且很难知道哪个是正确的。 我重启了Xcode /computer等,还是一样!
附上截图:
- (NSString*) convertToDeviceTime:(NSString*) GMTDate {
//create the formatter for parsing
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//parsing the string and converting it to NSDate
NSDate *myGMTDate = [df dateFromString: GMTDate];
//create the formatter for the output
NSDateFormatter *out_df = [[NSDateFormatter alloc] init];
[df setTimeZone:[NSTimeZone systemTimeZone]];
[out_df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//output the date
NSString *myDeviceDate =[out_df stringFromDate:myGMTDate];
NSLog(@"the date is %@",myDeviceDate);
return myDeviceDate;
}
下面的新截图 - 这一定是 Xcode 有问题, 'token' 的实际值显示在快速查看中,但调试器 window 将其显示为日期!诡异的。我重启了Mac,还是一样
更新:所有 NSString 变量都会发生这种情况。只要我向它们写入一个值,调试器 window 就会向它们显示相同的日期值。如果我将它们打印到控制台或 NSLog,那么这些值就会正确显示。
找到罪魁祸首。 在调试器的 "Edit Summary Format" 弹出窗口中,我不知何故无意中粘贴了这个日期值,它显示了所有 NSString 值。
仅供参考:它不是特定于项目的,所以当我加载另一个项目时,它保留了 "Edit Summary Format" 字符串并将其应用于所有 NSString。
在此向较旧的 SO post 致敬:
附上截图!