NSDate initWithString [英] NSDate initWithString
问题描述
将Xcode更新到4.2版之后,我在当前项目中收到以下警告:
After updating Xcode to version 4.2 I received the following warning in my current project:
警告:"NSDate"可能不会响应"initWithString:"
warning: 'NSDate' may not respond to 'initWithString:'
我该怎么办? :)
推荐答案
此方法仅在Mac OSX页面(而不是iOS)上说明的文档中. 我不清楚为什么苹果拥有不同的版本,但幸运的是,他们的反应是相同的.
This method is in the documentation only noted at the Mac OSX page, not the iOS. Why Apple has different versions is unclear to me, but they luckily respond the same.
因为iOS的类引用说iOS NSDate没有这种方法,所以您会得到警告. 但是,您的代码会很好地响应.
Because the class reference for iOS says there is no such method for iOS NSDate, you get the warning. Your code, however, will respond perfectly fine.
要使警告静音,您实际上应该使用NSDateFormatter.
To silence the warning, you should indeed use NSDateFormatter.
此致
Jacco
这篇关于NSDate initWithString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!