swift
-
LottieSwift/Tips & Tricks 2022. 5. 27. 11:24
iOS Lottie 다루는 법 1. Cocoapods 에 추가한다. 2. lottiefiles.com 에 가서 원하는 Animation 을 다운 받는다. 3. XCode Project 로 가져온다. 4. import Lottie 5. 코드 import UIKit import Lottie class ViewController: UIViewController { let animationView = AnimationView() override func viewDidLoad() { super.viewDidLoad() setupAnimation() } private func setupAnimation() { animationView.animation = Animation.named("paperplane") ani..
-
Code Snippet (Xcode)Swift/Tips & Tricks 2022. 5. 13. 10:37
Snippet 을 이용하면 반복되는 코드를 빠르게 작성할 수 있다. 단축키는 Shift + Command + L 여기에 Completion 을 보면 'closure' 라고 쓰여있는데, 이는 XCode 에서 'closure' 을 입력 시 바로 코드를 완성 할 수 있다는 의미인 듯 하다. 선택하면 아래와 같이 바로 코드를 빠르고 쉽게 완성 시키는 데 많은 도움이 된다. Code Snippet 생성 1. Code Snippet 을 생성하기 원하는 영역을 드래그 후 우클릭 -> Create Code Snippet 선택 2. 해당 화면이 노출되고, 여기에서 편집이 가능하다. 3. Xcode 에서 일반적으로 제공하는 Code Snippet 은 Place Holder 가 제공되고, place holder 는 을 사용..
-
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..
-
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 ..
-
Xcode Tips (With SwiftUI)끄적끄적 2021. 12. 14. 13:52
Simulator toggle darkMode : Command + Shift + A XCode show / hide navigator (좌측 바) : Command + 0 show / hide inspectors (우측 바): Command + Option + 0 show / hide debug area(하단 바): Command + Shift + Y Update Preview (SwiftUI) : Command + Option + p Command + Click (on element in canvas preview ) -> 수정 및 해당 Contents 의 Code 부분 확인 가능.
-
Combine-Chap7_Sequence OperatorCombine 2021. 12. 10. 18:01
import Foundation import Combine var subscriptions = Set() func example(of name: String, closure: () -> Void) { print("-----------------\(name)----------") closure() } example(of: "hi") { print("hi") } example(of: "min") { let publisher = [1,-50,246,0].publisher publisher .print("publisher") .min() .sink(receiveValue: {print("Lowest value is \($0)")}) .store(in: &subscriptions) } // using own co..
-
Combine_Chap5_CombiningOperatorsCombine 2021. 11. 26. 17:42
import UIKit import Combine var greeting = "Hello, playground" var subscriptions = Set() func example(of name: String, closure: () -> Void) { print("--------------------------\(name)--------------------------") closure() } example(of: "prepend(Output...)") { let publisher = [3,4].publisher publisher .prepend(1,2) .prepend(-1,0) .sink(receiveValue: {print($0)}) .store(in: &subscriptions) } exampl..