I can\'t convert my NSString to NSDate. here\'s the code:
+ (NSDate *) stringToNSDate: (NSString *) dateString{
[NSDateFormatter setDefaultFormatterBehavior:NSDa
From the information you've given, the problem appears to be that your dateString separates the date components with slashes (\), but your date formatter is expecting dashes (-).
To answer your other question, you can use stringByReplacingOccurrencesOfString:withString:.
For example:
NSString *date1 = @"2012/12/10 ...";
NSString *date2 = [date1 stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
Note that this will replace every / with -, so just be careful about timezones etc.
Try this instead:
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss ZZZ"];