NSDate initWithString

After upgrading Xcode to version 4.2, I received the following warning in the current project:

warning: "NSDate" may not respond to "initWithString:"

What should I do?:)

+2
objective-c nsdate
Oct 14 '11 at 15:54
source share
3 answers

This method is indicated in the documentation marked only on the Mac OSX page, not on iOS. Why Apple has different versions is not clear to me, but they, fortunately, answer the same.

Since the class reference for iOS says that there is no such method for iOS NSDate, you will receive a warning. However, your code will respond perfectly.

To turn off the warning, you really have to use NSDateFormatter.

Hello,

Jacco

+3
Oct 18 2018-11-11T00:
source share

You must use NSDateFormatter to get the NSDate object from the string. This will give you more flexibility regarding the format of the input string.

NSDateFormatter Help

+1
Oct. 14 '11 at 15:57
source share

Read the changes on this site http://developer.apple.com/library/ios/#releasenotes/General/iOS42APIDiffs/index.html Sometimes they change small syntax things and do new and better ways to do things.

0
Oct. 14 '11 at 15:58
source share



All Articles