NSString から NSDate を取得しようとしました。次のコードを使用します。
NSString *string = @"Wednesday";
NSError *error = nil;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeDate error:&error];
if (!error) {
NSArray *matches = [detector matchesInString:string
options:NSMatchingReportCompletion
range:NSMakeRange(0, string.length)];
NSArray *dates = [matches valueForKey:@"date"];
NSLog(@"%@", dates);
}
私の文字列が「今日」、「明日」、またはその後の時間のない曜日である場合、iOS 8 では何も得られませんが、iOS 9 は「今日」の現在の日、「明日」からの明日、および「週からの翌週日」を返します日"。結果を統一する方法を知っている人はいますか?