我确定这确实很简单,但我不确定如何搜索它,因为我已经看到了我认为称为编译器标志的例子,但总的来说是什么在支持它的操作系统版本上以可信方式运行特定方法的最佳方法。作为一个例子,NSDateFormatter类具有setDoesRelativeDateFormatting方法,该方法仅适用于10.6(在Mac上)和更高版本。基于操作系统版本的条件方法
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSLocale *enLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormatter setLocale:enLocale];
[dateFormatter setDoesRelativeDateFormatting:YES];
如何防止编译引发基于SDK的警告? – acidprime