iphone - NSDate dateFromString deprecated? -


I'm trying to use the NSDate dateFromString method, but I'm getting a warning and crashing this app Used to be. Code looks like this:

  NSString * pickerDate = [NSString stringWithFormat: @ "% @", Time Selector.date]; NSDate * defaultDate = [NSDate dateFromString: pickerDate];  

The warning is:

  'NSDate' can not answer 'dateFromString'  

The method seems to have been deprecated (between XCode 2 to 3 in the middle of the upgrade.

What alternative method can I use to create a date from a string?

NSDateFormatter one nsdit for you NSString .

The most basic use is something like this:

  NSString * dateString = @ "3- Agus NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init] autorelease; dateFormatter.dateFormat = @ "d-MMM-yy"; NSDate * date = [dateFormatter dateFromString: dateString];   

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -