简体   繁体   中英

How to translate the following code snippet from Swift to Objective-C?

How to translate the following code snippet from Swift to Objective-C?

#if compiler(>=5.5)
if #available(iOS 15.0, *) {
    myTableView.sectionHeaderTopPadding = 0.0
}
#endif

Alternatively, is there any macro in objective c side that assists to know the compiler version?

UPDATE:

@Cy-4AH suggested and answer that used,

#ifdef __IPHONE_13_0
if (@available(iOS 13.0, *)) {
    ...
}
#endif

However, in my case #ifdef __IPHONE_15_0 is not available in Xcode12.x

I have managed to solve this problem with a workaround discussed here .

#if __clang_major__ >= 12
    NSLog(@"My Objective-C language support is what Apple Clang/Xcode 12.x can support.");
#endif

Note that clang_major or clang_minor etc. variables resembles (almost same to) Xcode versions and need carefully investigated before the usage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM