목록전체 글 (127)
소피it블로그
https://www.hackingwithswift.com/100/15 Day 15 – 100 Days of Swift Follow the 100 Days of Swift and learn to build apps for free. www.hackingwithswift.com 1. 프라퍼티 옵저버: 구조체와 클래스는 자기만의 변수와 상수를 가질 수 있는데, 이를 프라퍼티라고 한다. 프라퍼티 옵저버는 프라퍼티의 값이 바뀌기 전이나 바뀐 직후에 실행되는 코드로, willSet과 didSet이 있음. 2. computed property: 만들려면 프라퍼티 뒤에 중괄호를 열고 적절한 시간에 적절한 액션을 취하게 해줄 get이나 set을 써준다. 3. Static property: 스위프트에서는 타입의 인스턴스..
https://www.hackingwithswift.com/100/14 Day 14 – 100 Days of Swift Follow the 100 Days of Swift and learn to build apps for free. www.hackingwithswift.com 1. external parameter name을 정할 때 _를 사용하면 편리한 경우가 많지만, "in", "for", "with"와 같은 이름을 사용하는 게 더 스위프트적인 방식이다. 의미있는 internal names와 함께 사용. 2. 옵셔널 func getFood(mood: String) -> String? { if mood == "sad" { return nil } else { return "Burger" } } var f..
https://www.hackingwithswift.com/100/13 Day 13 – 100 Days of Swift Follow the 100 Days of Swift and learn to build apps for free. www.hackingwithswift.com 어제 하루 빼먹은 만큼 오늘은 이틀치를 정리해보려고 한다. 다행히 day 13부터 3일간은 복습 컨텐츠라 심적으로 큰 부담은 없었다. 1. constants and variables: 가능한 한 변수보다는 상수를 씀으로써 코드를 더 이해하기 쉽게 만들자. 실제로 변수를 선언해놓고 쓰지 않으면 스위프트에서 경고를 날려줄 것이다. 2. Double vs Float: Double has the highest accuracy. float는..
https://www.hackingwithswift.com/100/12 Day 12 – 100 Days of Swift Follow the 100 Days of Swift and learn to build apps for free. www.hackingwithswift.com 1. 옵셔널: 값이 없을 수도 있는 경우에 사용하며, 모든 타입에 대하여 만들 수 있다. 옵셔널은 옵셔널이 아닌 값과 함께 연산해줄 수 없다. 같은 타입이 아니기 때문 var name: String? = nil name = "Sophie" ⭐️ 2. "optional binding" (unwrapping optionals): 옵셔널은 언래핑하기 전에는 사용할 수 없다. 언래핑 방법에는 if let과 guard let이 있다. var..