gpt4 book ai didi

ios - 我已经为聊天应用程序编写了代码,适用于 iOS 12,但在 iOS 13 中,它返回 nil 值

转载 作者:行者123 更新时间:2023-11-28 23:25:54 25 4
gpt4 key购买 nike

enter image description here我为聊天应用程序编写了代码,适用于 iOS 12,在 iOS 13 中,它返回 nil 值。

这是我的 dateformatter 代码片段。

-(NSDate *)stringToDateNew:(NSString*)strDate withForamt:(NSString *)strFormat {
@try
{
NSDate *myDate;

if(strDate!=NULL)
{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:[NSString stringWithFormat:@"%@",strFormat]];
NSLocale * enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] ;
if (enUSPOSIXLocale == nil) {
enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
}
else
{
[dateFormat setTimeZone:[NSTimeZone systemTimeZone]];
[dateFormat setLocale:enUSPOSIXLocale];
myDate = [dateFormat dateFromString:strDate];
return myDate;
}

}
return NULL;

}
@catch (NSException *exception)
{
NSLog(@"Excption in AppDelegate : stringToDate %@:%@",exception.name,exception.reason);
}
}

最佳答案

使用格式“yyyy-mm-dd'T'hh:mm:ss.SSS”。它也适用于 os 13。

关于ios - 我已经为聊天应用程序编写了代码,适用于 iOS 12,但在 iOS 13 中,它返回 nil 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58742761/

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