목록Swift (13)
개발자의 삽질
https://developer.apple.com/documentation/swift/array Apple Developer Documentation developer.apple.com Swift 에서 2차원 배열 만들기! Array(repeating: Element, count: Int) 를 사용하면 된다. /* [ [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1] ] */ let arr0 = Array(repeating: Array(repeating: 1, count: 5), count: 4) let arr1 = Array(repeating: [Int](repeating: 1, count: 5), count: 4) let arr2 = Array(repeatin..
https://www.hackingwithswift.com/quick-start/beginners/how-to-limit-access-to-internal-data-using-access-control How to limit access to internal data using access control - a free Swift for Complete Beginners tutorial Was this page useful? Let us know! 1 2 3 4 5 www.hackingwithswift.com public, private 에 대해 알아보자. 바로 예시로 간다. public 밖에서 읽기도 쓰기도 가능하다. struct BankAccount { var funds = 0 } let accoun..
https://stackoverflow.com/questions/24032754/how-to-define-optional-methods-in-swift-protocol How to define optional methods in Swift protocol? Is it possible in Swift? If not then is there a workaround to do it? stackoverflow.com Swift 에서는 어떻게 Optional Protocol 을 만들까? Objective-C 에서는 매우 간단하게 Optional Protocol을 만들 수 있다. 애초에 언어에서 지원을 하기 때문이다. 예를 한번 들어보자 @protocol ProtocolWithOptional - (void) ret..
https://docs.swift.org/swift-book/ReferenceManual/Attributes.html Attributes — The Swift Programming Language (Swift 5.6) Attributes There are two kinds of attributes in Swift—those that apply to declarations and those that apply to types. An attribute provides additional information about the declaration or type. For example, the discardableResult attribute on a function d docs.swift.org @disca..
https://docs.swift.org/swift-book/LanguageGuide/Initialization.html Initialization — The Swift Programming Language (Swift 5.6) Initialization Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization t docs.swift.or..
https://docs.swift.org/swift-book/LanguageGuide/Initialization.html Initialization — The Swift Programming Language (Swift 5.5) Initialization Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization t docs.swift.or..
https://docs.swift.org/swift-book/LanguageGuide/Initialization.html Initialization — The Swift Programming Language (Swift 5.5) Initialization Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization t docs.swift.or..
https://developer.apple.com/documentation/swift/choosing_between_structures_and_classes Apple Developer Documentation developer.apple.com 생각 없이 애플 디펠로퍼 사이트를 여기저기 돌아다니다가. 노다지 같은 글을 발견해버렸다. 그래서 바로 블로깅(번역)을 시작한다. Choosing Between Structures and Classes Overview 구조체와 클래스는 모두 데이터를 저장하고 앱의 동작을 모델링하기에 좋은 선택이다. 그러나 서로 비슷한 점들이 있어서 둘 중 어떤 것을 선택해야 할지 약간의 어려움이 있다. 따라서 앱에 새로운 데이터 타입을 추가할 때 다음 4가지 사항을 고려해보자 기..