Swift
-
SubjectsSwift/RxSwift 2022. 3. 25. 00:44
import UIKit import RxSwift func example(of description: String, action: () -> Void) { print("\n--- Example of:", description, "---") action() } Observables are a fundamental part of RxSwift, but they’re essentially read-only. You may only subscribe to them to get notified of new events they produce. A common need when developing apps is to manually add new values onto an observable during runti..
-
Rx Swift Cocoa pods 로 설치하기, playground 연습 환경 구축Swift/Tips & Tricks 2022. 3. 23. 00:08
설치하기 !!! 1. Cocoapods 를 설치한다. (Terminal 에 입력) sudo gem install cocoapods 2. Current Folder 로 이동한다. 3. pod init -> podfile 이 생성된다. pod init 4. podfile 로 들어가서 수정 후 저장, 닫는다. # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'RxSwiftProj' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for RxSwiftProj po..
-
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 Tips and Tricks - .enumerated()Swift/Tips & Tricks 2021. 10. 12. 13:21
Swift 에서 for statement 내에 종종 .enumerated() 가 쓰일 때가 있어요. ( enumerate: 열거하다, 세다 ) 먼저, 예시부터 드릴게요 ! let names = ["james", "kelvin", "katherine"] for (idx, name) in names.enumerated() { print("idx: \(idx), name: \(name)") } //idx: 0, name: james //idx: 1, name: kelvin //idx: 2, name: katherine 주로 위 예시와 같이 index 와 함께 사용합니다. Syntax 는 위와 같이 (index, element) 로 써주시면 편해요! 이제, option + click 설명과 함께 알아보아요. S..