Swift/availability condition: Difference between revisions
Jump to navigation
Jump to search
imported>Fire Created page with "[https://www.swiftlangjp.com/language-reference/statements.html#%E3%82%A2%E3%83%99%E3%82%A4%E3%83%A9%E3%83%93%E3%83%AA%E3%83%86%E3%82%A3%E6%9D%A1%E4%BB%B6availability-condition Availability Condition] を使うと実行時にOSの種類によって、制御を変えることができる。(conditional compilation blockは、コンパイル時に判断され、バイナリに反映される。) == Syntax == platform-name は..." |
(No difference)
|
Latest revision as of 19:53, 8 November 2022
Availability Condition を使うと実行時にOSの種類によって、制御を変えることができる。(conditional compilation blockは、コンパイル時に判断され、バイナリに反映される。)
Syntax
platform-name は、"iOS", "macOS", "macCatalyst", "watchOS", "tvOS" が指定できる。複数並べることができるが、orやand条件にはできない。*をつけないと怒られる(将来のバージョンも対応する印)
if #available(platform-name version, ..., *) {
...
} else {
...
}