본문 바로가기
Cocoa Touch Cocoa & CocoaTouch Cocoa and Cocoa Touch are the application development environments for OS X and iOS, respectively. Both Cocoa and Cocoa Touch include the Objective-C runtime and two core frameworks: - Cocoa, which includes the Foundation and AppKit frameworks, is used for developing applications that run on OS X. - Cocoa Touch, which includes Foundation and UIKit frameworks, is used for devel.. 2021. 2. 16.
Swift - 고차함수, Higher-order function 고차함수 고차함수(Higher-order function) : ‘다른 함수를 전달인자로 받거나 함수실행의 결과를 함수로 반환하는 함수’를 뜻한다. 스위프트의 함수(클로저)는 일급시민이기 때문에 함수의 전달인자로 전달할 수 있고 함수의 결과값으로 반환할 수 있으므로, 고차함수이다 스위프트 표준라이브러리에서 제공하는 유용한 고차함수 1. map map함수는 컨테이너 내부의 기존 데이터를 변형(transform)하여 새로운 컨테이너를 생성 let numbers: [Int] = [0, 1, 2, 3, 4] var doubledNumbers = numbers.map({ (number: Int) -> Int in return number * 2 }) print(doubledNumbers) // [0, 2, 4, 6.. 2021. 2. 10.
Swift19 - 익스텐션 Extensions Extensions add new functionality to an existing class, structure, enumeration, or protocol type. Extensions in Swift can: Add computed instance properties and computed type properties Define instance methods and type methods Provide new initializers Define subscripts Define and use new nested types Make an existing type conform to a protocol 익스텐션이란? - 익스텐션은 구조체, 클래스, 열거형, 프로토콜 타입에 새로운.. 2021. 2. 10.
Swift18 - 프로토콜 Protocols A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol. In addition to specifying require.. 2021. 2. 10.
Swift17 - assert/guard assert(_:_:file:line:) func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) Use this function for internal sanity checks that are active during testing but do not impact performance of shipping code. assert 함수 assert(_:_:file:line:) 함수를 사용합니다. assert 함수는 디버깅 모드에서만 동작합니다. 배포하는 애플리케이션에서는 제외됩니다. 예상했던 조건의 검.. 2021. 2. 10.
Swift16 - 타입캐스팅 Type Casting Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy. 타입캐스팅? - 인스턴스의 타입을 확인 하는 용도 - 클래스의 인스턴스를 부모 클래스의 타입으로 사용할 수 있는지 확인 하는 용도 - 클래스의 인스턴스를 자식 클래스의 타입으로 사용할 수 있는지 확인 하는 용도 - is, as를 사용 * 스위프트의 형변환 != 타입캐스팅 ex) let intVal: Int = 7 let doubleVal : Double = Double(intVal) >.. 2021. 2. 10.