This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
/*: | |
# Observables | |
*/ | |
// 옵저버블을 생성하는 방법 2 가지 | |
// #1 | |
Observable<Int>.create { (observer) -> Disposable in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
/*: | |
# Observers | |
*/ | |
let o1 = Observable<Int>.create { (observer) -> Disposable in | |
observer.on(.next(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
/*: | |
# Disposables | |
*/ | |
let subscription1 = Observable.from([1, 2, 3]) | |
.subscribe(onNext: { elem in | |
print("Next", elem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// 1 Originator 를 정의한다. | |
class Game { | |
public var level = 0 | |
public var score = 0 | |
/// 레벨을 설정하는 메소드 | |
public func setLevel(level: Int) { | |
self.level = level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// 1 Product를 만든다. | |
public struct Hamburger { | |
public let meat: Meat | |
public let sauce: Sauces | |
public let toppings: Toppings | |
} | |
extension Hamburger: CustomStringConvertible { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImageView { | |
func enableZoom() { | |
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(startZooming(_:))) | |
isUserInteractionEnabled = true | |
addGestureRecognizer(pinchGesture) | |
} | |
@objc | |
private func startZooming(_ sender: UIPinchGestureRecognizer) { | |
let scaleResult = sender.view?.transform.scaledBy(x: sender.scale, y: sender.scale) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 아래 메소드를 SceneDelegate | |
// willConnect에 두고 추가된 이름을 확인할 것. 파일명과 폰트명이 달라서 보통 문제가 발생함. | |
// 1 이 메소드를 실행해서 폰트의 진짜이름을 찾는다. | |
for fontFamily in UIFont.familyNames { | |
for fontName in UIFont.fontNames(forFamilyName: fontFamily) { | |
print(fontName) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// No Storyboard | |
class ViewController: UIViewController { | |
var imageScrollView: ImageScrollView! | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
/* 단 하나의 이벤트를 전달할 때, 사용한다. */ | |
// 단 하나만 전달할 수 있기 때문에 onNext를 사용할 수 없다. | |
let disposeBag = DisposeBag() | |
let element = "😀" | |
/* 단 하나의 요소를 받아서 리턴하는 생성 연산자 */ | |
Observable.just(element) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
let disposeBag = DisposeBag() | |
let apple = "🍏" | |
let orange = "🍊" | |
let kiwi = "🥝" | |
/* 입력받은 요소에 각각 접근하는 옵저버블을 생성한다. */ |
OlderNewer