Skip to content

Instantly share code, notes, and snippets.

@helloooideeeeea
helloooideeeeea / closure.playground
Created December 9, 2016 10:35
Swift Closure オブザーバーデザインパターン
//: Playground - noun: a place where people can play
import Foundation
class Subscribe {
func fetch1 (complition: () -> Void ) {
// Api通信中..
print("1 loading...")
complition()
}
@helloooideeeeea
helloooideeeeea / protocol-observer.playground
Created December 9, 2016 06:26
Swift プロトコルで定義したオブザーバーパターン2
//: Playground - noun: a place where people can play
import Foundation
protocol Delegate: class {
func success(str: String, num: Int) -> String
}
// Modelだと思って
class Subscribe {
@helloooideeeeea
helloooideeeeea / protocol-observer.playground
Created December 9, 2016 06:18
Swift: protocolで定義したオブザーバーパターン
//: Playground - noun: a place where people can play
import Foundation
protocol Delegate: class {
func foo()
func bar(num: Int)
func buz(str: String, num: Int) -> String
}
@helloooideeeeea
helloooideeeeea / notificationCenter.playground
Created December 9, 2016 06:12
swift : NotificationCenterで定義したオブサーバーパターン
//: Playground - noun: a place where people can play
import Foundation
// Observerを一括で管理するClass
class MyNotificationManager {
let center = NotificationCenter.default
func setMyNotification(clazz: Observer) {