ν°μ€ν 리 λ·°
π available μμ보기
available
μ μ¬μ©νμ¬ νΉμ Swift λ²μ λλ νΉμ νλ«νΌ λ° OSλ²μ κ³Ό κ΄λ ¨λ μ μΈμ μλͺ
μ£ΌκΈ°λ₯Ό λνλΈλ€.
μ¬μ©κ°λ₯ν μμ±(attribute)μ νμ λκ° μ΄μμ μΌνλ‘ κ΅¬λΆλ attribute argument λͺ©λ‘κ³Ό ν¨κ» λνλλ€.
μ΄λ¬ν argumentλ λ€μ νλ«νΌ λλ μΈμ΄ μ΄λ¦ μ€ νλλ‘ μμνλ€.
iOS
iOSApplicationExtension
macOS
macOSApplicationExtension
watchOS
watchOSApplicationExtension
tvOS
tvOSApplicationExtension
swift
#available ?
#available μ λ€μκ³Ό κ°μ΄ μ¬μ©λκ³ *
νμμ΄λ€. Bool μ λ°ννλ λ°νμ κ²μ¬μ΄λ€. κ·Έλμ λ°νμ μ€μ λͺ¨λλ₯Ό λ³κ²½ν΄λ λ°μμ΄ λλ€.
// β
if μμ μ¬μ©
if #available(iOS 14, *) {
print("This code only runs on iOS 14 and up")
} else {
print("This code only runs on iOS 13 and lower")
}
// β
guard μμ μ¬μ©
guard #available(iOS 14, *) else {
print("Returning if iOS 13 or lower")
return
}
print("This code only runs on iOS 14 and up")
@available ?
λ©μλλ₯Ό Swift, OS λ²μ λλ νλ«νΌμ λ²μ μ λ°λΌμ μ νν μ μλ€.
@available
μ ν¨μ(λ©μλ), ν΄λμ€ λλ νλ‘ν μ½ μμ λμΈλ€. νμ
λλ νλ‘ν μ½μ΄ μ μ©λλ νλ«νΌ λ° OSλ₯Ό λνλΈλ€.
#available
κ³Ό λ€λ₯΄κ², μ»΄νμΌ νμμ κ²½κ³ λλ μ€λ₯λ₯Ό μμ±ν©λλ€.
@available(iOS 12, *)
func setupDoneButton() { }
// λ€μκ³Ό κ°μ΄ μ¬μ© κ°λ₯
@available(iOS 12.0, macOS 10.12, *)
func setupDoneButton() { }
deployment target μ¦, μ΅μνμΌλ‘ μ§μνλ OS λ²μ μ΄ 10.0 μΈ κ²½μ°μ μμ setupDoneButton()
λ©μλλ λ€μκ³Ό κ°μ΄ μ¬μ©λλ€.
if #available(iOS 12, *) {
self.setupDoneButton()
} else {
// Fallback on earlier versions
}
μΆμ²
'iOS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
iOS) Closure ννλ°©λ² (0) | 2021.10.13 |
---|---|
iOS) λ€ν¬ λͺ¨λ λμνκΈ° (0) | 2021.10.11 |
iOS) UIModalTransitionStyle.partialCurl μμ보기 (0) | 2021.10.09 |
iOS) UICollectionView μ€ν¬λ‘€μ λ°λΌ κ°μ΄ μμ§μ΄λ μλ¨ λ° κ΅¬ννκΈ° (0) | 2021.10.06 |
iOS) UIScrollViewDelegate μ λν΄ μμ보μ(Scrolling and Dragging) (0) | 2021.10.06 |
- WidgetKit
- configurable widget
- watchOS
- μλ²ν΅μ
- MOYA
- OpenSourceLibrary
- Protocol
- 2022 KAKAO TECH INTERNSHIP
- Swift
- SwiftUI
- YPImagePicker
- containerBackground
- Algorithm
- IOS
- APNS
- RxCocoa
- WWDC
- Objective-C
- Notification
- UserDefaults
- MVVM
- urlsession
- WWDC22
- Firebase
- Widget
- async/await
- github
- projectsetting
- CloneCoding
- rxswift
μΌ | μ | ν | μ | λͺ© | κΈ | ν |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Total
- Today
- Yesterday