「Objective-C入門」文字列から日付を取得する方法

サンプルコード

NSDateFormatter *dateFmtter = [[NSDateFormatter alloc] init];
dateFmtter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
dateFmtter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'";
dateFmtter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];

NSString *strcft = @"2017-04-12T21:20:50Z";
NSDate *date = [dateFormatter dateFromString:strcft];

IOS

Posted by arkgame