我已经为聊天应用程序编写了代码,适用于 iOS 12,但在 iOS 13 中,它 return 零值

I have written code for chat application, works fine for iOS 12 but in iOS 13, it return nil value

我已经为聊天应用程序编写了代码,在 iOS 12 中工作正常,在 iOS 13 中,它 return 零值。

这是我的 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。