Swift Language
-
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-..
-
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 에서는 그냥 되기 때문에 신경쓰지 않아도 된다. ) 해당..
-
Swift Language) sort, map, filter, reduceSwift/Tips & Tricks 2021. 9. 29. 13:57
sort, sorted sort: 자신 (array) 를 정렬 sorted: array 를 정렬해서 return (새로운 값에 할당, array 자체는 그대로 유지) var numArr = [1,3,2,1,5] let newArr = numArr.sorted() // newArr: [1,1,2,3,5], numArr: [1,3,2,1,5] numArr.sort() // numArr: [1,1,2,3,5] numArr.sort(by: >) // decending order. // numArr: [5,3,2,1,1] map array의 각 element 에 대하여 어떤 logic 을 수행, logic 이 적용된 각 element 를 새로운 array 로 묶어 return ( 순서 유지) let numArr ..
-
Swift Language ) GenericsSwift/Swift Language 2021. 9. 23. 13:46
Generics Generic 은 유연하고 재사용 가능하도록 함수와 타입을 다룰 수 있게 해주고, 어떠한 type, subject 와도 함께 사용될 수 있어요. 이를 통해 중복되는 코딩을 하지 않을 수 있습니다. 대부분의 Swift standard library 는 generic 으로 이루어져있고, Generic 은 Swift 의 가장 강력한 기능 중 하나에요. 예를 들면, Swift 에서 array, dictionary 는 모두 generic collections 이에요. 따라서 Int, String 뿐만 아니라 Swift 내에서 생성될 수 있는 어떠한 타입이든 array 의 element 로서 존재할 수 있습니다. (dictionary 내 element 도 마찬가지에요) 1.1 The Problem..