본문 바로가기

Swift59

[Swift] Extension에 Stored Property를 못 넣는 이유 Swift Interview Questions and Answers In this tutorial, you’ll work through a series of Swift-specific interview questions and answers. www.raywenderlich.com Why does Swift not allow stored properties in extensions? I've been trying to find the best way to implement a stored property in an extension, and came across this question: Swift extension stored properties alternative. However, I have no.. 2022. 9. 27.
[Swift] Generic where clause 사용 시 '==' vs ':' 비교하는 Generic Type이 class인 경우 public extension Array where Element == UIView { func testable1() { } } public extension Array where Element: UIView { func testable2() { } } Element == UIVew 무조건 Element가 UIView여야 됨. (ex: Element가 UIControl, UIButton 이면 접근 불가) EX) var arr: [UIView] Element: UIView Element가 UIView를 상속받으면 됨 (ex: Element가 UIControl, UIButton 여도 접근 가능) EX) var arr: [UIView], var arr2: [.. 2022. 9. 25.
[Swift] JSON Decoding, Encoding [Swift] Codable - Decoding 방법 이전 포스트는 Codable의 Encodable에 대해 알아 보았습니다. 이번 포스트는 Codable의 Decodable에 대해 알아보도록 하겠습니다. Decodable JSON 데이터를 디코딩 하는 방법에 대해 알아보도록 하겠습니다. De jinnify.tistory.com Decodable을 이용한 JSON 디코딩 import Foundation extension Data { func decode(_ type: T.Type) -> T? where T : Decodable { do { let result = try JSONDecoder().decode(T.self, from: self) return result } catch { print(error.. 2022. 9. 5.
[Swift] Swift Object Lifetime https://www.raywenderlich.com/966538-arc-and-memory-management-in-swift#toc-anchor-003 ARC and Memory Management in Swift In this tutorial, you’ll learn how ARC works and how to code in Swift for optimal memory management. You’ll learn what reference cycles are, how to use the Xcode 10 visual debugger to discover them when they happen and how to break them using an exampl www.raywenderlich.com S.. 2022. 8. 26.