我已经为聊天应用程序编写了代码,在iOS 12上运行良好,但在iOS 13中,它返回的值为零

我已经为聊天应用程序编写了代码,在iOS 12上运行良好,但在iOS 13中,它返回的值为零,ios,objective-c,nsdateformatter,Ios,Objective C,Nsdateformatter,我已经为聊天应用程序编写了代码,在iOS 12上运行良好,在iOS 13中,它返回nil值 这是我的dateformatter代码片段 -(NSDate *)stringToDateNew:(NSString*)strDate withForamt:(NSString *)strFormat { @try { NSDate *myDate; if(strDate!=NULL) { NSDateFormatter *da

我已经为聊天应用程序编写了代码,在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。

请回答您的问题,并指出导致问题的确切行。还包括有关传递到方法中的值的特定详细信息。现在检查@rmaddyth以显示格式,但传递到strDate参数的值是什么?传递日期的格式为2019年10月20日@rmaddydy您认为2019年10月20日的字符串是否与yyyy-MM-dd'T'HH:MM:ss.zzz的格式匹配?您需要传递一个与您试图解析的日期字符串实际匹配的格式。