我確定這確實很簡單,但我不確定如何搜索它,因爲我已經看到了我認爲稱爲編譯器標誌的例子,但總的來說是什麼在支持它的操作系統版本上以可信方式運行特定方法的最佳方法。作爲一個例子,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