NSDate initWithString

后端 未结 3 1213
半阙折子戏
半阙折子戏 2021-01-21 16:43

After updating Xcode to version 4.2 I received the following warning in my current project:

warning: \'NSDate\' may not respond to \'initWithString:\'

3条回答
  •  花落未央
    2021-01-21 17:40

    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.

    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.

    To silence the warning, you should indeed use NSDateFormatter.

    Regards,

    Jacco

提交回复
热议问题