warning no-method descriptionWithCalendarFormat:timeZone:locale found

人盡茶涼 提交于 2019-12-11 07:47:22

问题


I am getting this warning in xcode 3.1.3 iphone os 3.0.

This method is also not available in the NSDate class. But I am getting the date from this method.

Can anyone please tell me How can I get rid of this warning????


回答1:


You'll want to use NSDateFormatter instead. descriptionWithCalendarFormat:timeZone:locale: landed on the "non-public API" list recently, and is grounds for rejection of your app.

Here's an example of how you can use NSDateFormatter:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMM d y"];
NSString *dateString = [dateFormatter stringFromDate:date];
return dateString;

Note that the format string is the Unicode standard, not the printf-style version. You can find the spec here: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns




回答2:


These are undocumented private API methods. Using them will get your app rejected by Apple. Use only the documented methods of NSDate.



来源:https://stackoverflow.com/questions/1163589/warning-no-method-descriptionwithcalendarformattimezonelocale-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!