简体   繁体   English

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

[英]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.

相关问题 React Native IOS 应用程序在 IOS 版本 15 和 14 上运行良好,但在 IOS 12 和 13 的初始屏幕上崩溃 - React Native IOS App works fine on IOS version 15 and 14 but crashes on splash screen for IOS 12 and 13 UIView 未在 iOS13 中删除,它适用于 iOS 12 - UIView not removed in iOS13, It works in iOS 12 ios keychain返回nil值 - ios keychain return nil value 我已将 Widgetkit 添加到我的应用程序中,但现在当应用程序在 Xcode 12 beta 上启动时在 iOS 13 上崩溃 - I have added Widgetkit to my app but now crash on iOS 13 when the app starts on Xcode 12 beta iOS / FBSDK-FBSDKProfile在设备上为零,在模拟器上可以正常工作 - iOS/FBSDK - FBSDKProfile is nil on device, works fine on simulator IOS 13 UIWindow 实例在应用程序启动期间为零 - IOS 13 UIWindow instance is nil during application launching iOS 13 将 UITextView 转换为图像的 UITextView 无法正常工作。 在 iOS 12 以下工作正常 - iOS 13 UITextView converting UITextView to image is not working properly. Working fine in below iOS 12 iOS错误:在iOS12上运行项目会出现错误,但在iOS11上运行正常 - iOS Error: Running the project on iOS12 gives an error, but it works fine on iOS11 CTTelephonyNetworkInfo 在 iOS 12 上返回 nil - CTTelephonyNetworkInfo returning nil on iOS 12 iOS8的Autolayout问题,代码在iOS7上运行良好 - Autolayout problems with iOS8 with code that works fine on iOS7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM