iOS/🟠 Swift

[Swift] Swift 5.8 CHANGELOG

woozzang 2022. 11. 27. 02:28

 

SE-0365

이제 ν΄λ‘œμ € λ‚΄λΆ€μ—μ„œ [weak self] 둜 μΊ‘μ²˜ν•œ self λ₯Ό μ–Έλž˜ν•‘ν•œ μ΄ν›„μ—λŠ” self λ₯Ό μƒλž΅ν•΄λ„ λ©λ‹ˆλ‹€.

class ViewController {
  let button: Button

  func setup() {
      button.tapHandler = { [weak self] in
          guard let self else { return }
          dismiss() // refers to `self.dismiss()`
      }
  }

  func dismiss() { ... }
}

 

Swift 5 μ—μ„œλŠ” non-escaping ν΄λ‘œμ €μ—μ„œ [weak self] 이후 self λ₯Ό λͺ…μ‹œμ μœΌλ‘œ μ–ΈκΈ‰ν•˜μ§€ μ•Šμ•„λ„ λ˜μ—ˆμ§€λ§Œ,

Swift 6 λ²„μ „λΆ€ν„°λŠ” 더 이상 ν—ˆμš©λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

self λ₯Ό μ–Έλž˜ν•‘ν•˜κ±°λ‚˜, [unowned self] λ₯Ό μ‚¬μš©ν•΄μ•Όλ§Œ μƒλž΅κ°€λŠ₯ν•©λ‹ˆλ‹€.

 

SE-0362

컴파일러 ν”Œλž˜κ·Έ -enable-upcoming-feature X λ₯Ό 톡해

evolution process μ—μ„œλŠ” 승인 λ˜μ–΄ λ‹€μŒ 메이저 버전(eg. Swift 6 )에 λ„μž…λ  μ˜ˆμ •μΈ κΈ°λŠ₯을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

ν˜„μž¬ μ‚¬μš© κ°€λŠ₯ν•œ κΈ°λŠ₯은 μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€:

  • ConciseMagicFile enables the new #file semantics in SE-0274.
  • ForwardTrailingClosures disables the "backward" scanning behavior of SE-0286.
  • BareSlashRegexLiterals enables the regex literal syntax of SE-0354.

 

μ•„λž˜ μ½”λ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ μ‚¬μš©κ°€λŠ₯ν•œ κΈ°λŠ₯을 탐지할 수 μžˆμŠ΅λ‹ˆλ‹€.

#if hasFeature(X)

 

 


μ˜€λŠ˜λ„ λ‚˜λŠ” μ„±μž₯ν–ˆλ‹€!!πŸ”₯

 

πŸ€– [Back to the Basics] πŸ’»
μ£Όλ‹ˆμ–΄ iOS 개발자 우짱의 기술 λΈ”λ‘œκ·Έμž…λ‹ˆλ‹€.

 

[μ°Έκ³  자료 πŸ™‡πŸ»‍♂️]

https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md

 

GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhancements to the Swift Programming Lang

This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhance...

github.com

https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md

 

GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhancements to the Swift Programming Lang

This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhance...

github.com