Swift/Swift Language
-
Swift KVO ( Key Value Observing, Reactive Programming)Swift/Swift Language 2022. 4. 14. 00:17
// // ViewController.swift // KVO // // Created by Kyle Lee on 10/12/18. // Copyright © 2018 Kyle Lee. All rights reserved. // import UIKit class User: NSObject { // send notification (dynamic) @objc dynamic var name = String() @objc var age = 0 { willSet { willChangeValue(forKey: #keyPath(age))} didSet { didChangeValue(for: \User.age)} } } class ViewController: UIViewController { @IBOutlet weak..
-
Swift Language ) PropertiesSwift/Swift Language 2022. 1. 17. 14:12
Properties Properties 는 어떤 class, structure 또는 enumeration 과 values 를 연관시킨다. Stored properties 는 constant or variable values 를 instance 의 일부로 저장하고, computed properties 는 value 를 계산한다. Computed properties 는 classes, structures, enumerations 에서 사용 가능하고, Stored properties 는 classes, structures 에서만 사용 가능하다. Stored, computed properties 는 보통 특정 타입의 instance 에 관련되지만, type 자체와도 관련될 수 있다. 이러한 properties ..
-
Assertions & PreconditionsSwift/Swift Language 2021. 11. 24. 18:13
Assertions and Preconditions Assertions 와 precondins 는 runtime 시 일어나는 확인작업이다. 코드를 더 실행하기 전에 필수 조건을 만족하는지 먼저 확인하기 위해 사용한다. 만약 assertion 이나 precondition 의 Boolean condition 이 true 라면 코드는 평상시와 같이 계속 진행된다. 그러나 그렇지 않은 경우, 코드 실행이 종료되고, 앱도 종료된다(terminated). 코딩 도중 본인이 가정하거나 예상하는 것을 확인하기 위해 이것들을 사용할 수 있다. Assertions 는 실수 또는 잘못된 가정을 개발 도중 확인 하는 데에, preconditions 는 production 에서 발생하는 문제들을 찾는 데에 사용할 수 있다. R..
-
Swift Language ) Error HandlingSwift/Swift Language 2021. 11. 23. 16:08
Error handling 은 프로그램 내 error conditions 에 대해 반응하고 recover 하는 과정이다. Swift 는 runtime 시 throwing, catching, propagating, manipulating recoverable erros 에 대해 first-class support 를 제공한다. 어떤 operations 는 실행을 완전히 마칠 수 없을 수 있고, 유용한 output 을 내지 못할 수도 있다. Optionals 는 값이 없음을 나타낼 때 사용된다. An operation 이 fail 될 때, 어떤 것이 failure 을 발생시켰는지 알면 그에 따라 반응할 수 있다. 예를 들어, disk 내에 있는 file 내 data 를 읽고 처리하는 과정에 대해 생각해보자...
-
Swift Language ) Advanced OperatorsSwift/Swift Language 2021. 11. 11. 19:57
오늘은 Advanced Operators 부분 중 Bitwise, Overflow parts 를 제외한, Custom Operators 위주로 번역을 진행해보겠습니다. (Bit 관련 부분은 추후 다시 포스팅 수정할 수 있으니 숨김글 처리하겠습니다.) 더보기 In addition to the operators described in Basic Operators, Swift provides several advanced operators that perform more complex value manipulation. These include all of the bitwise and bit shifting operators you will be familiar with from C and Objective-..
-
Structures And Classes (Swift)Swift/Swift Language 2021. 11. 1. 16:38
안녕하세요 ! 이번에는 Structure 과 Class 에 대해 Apple Documentation 을 번역하면서 공부할게요 . Structures and Classes Structures 와 Classes 는 많은 용도로 다양하게 쓰일 수 있는 constructs 이고, 이것들을 이용해서 program 의 code 가 구성되요. Structures 와 classes 에 properties, methods 를 정의하는 방식으로 기능을 추가할 수 있고, syntax 는 constants, variable,s functions 를 만들때와 같아요. 다른 프로그래밍 언어들과는 다르게 Swift 는 custom structures, classes 에 대해 별개의 interface 와 implementation ..
-
Swift Language ) ClosureSwift/Swift Language 2021. 10. 6. 18:43
1. Closures 1. Closures - 1.1 Closure Expressions 1.1.1 The Sorted Method 1.1.2 Closure Expression Syntax 1.1.3 Inferring Type From Context 1.1.4 Implicit Returns from Single-Expression Closures 1.1.5 Shorthand Argument Names 1.1.6 Operator Methods 1.2 Trailing Closures 1.3 Capturing Values 1.4 Closures Are Reference Types 1.5 Escaping Closures 1.6 Autoclosures Closures 는 pass 가능하고 코드에서 사용가능한 se..
-
Swift Language) ARC ( Automatic Reference Counting)Swift/Swift Language 2021. 10. 4. 20:47
Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift, and you don’t need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed. 예전에 위 bold 처리된 부분을 읽고 (메모리 관리가 Swift 에서는 그냥 되기 때문에 신경쓰지 않아도 된다. ) 해당..