[英]I have written code for chat application, works fine for iOS 12 but in iOS 13, it return nil value
I have written code for chat application,works fine for iOS 12,and in iOS 13, it return nil value.
我为聊天应用程序编写了代码,适用于 iOS 12,在 iOS 13 中,它返回 nil 值。
this is my code snippet for dateformatter.这是我的 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);
}
}
use the withformat "yyyy-mm-dd'T'hh:mm:ss.SSS".It Will work for os 13 as well.使用 withformat "yyyy-mm-dd'T'hh:mm:ss.SSS"。它也适用于 os 13。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.