Skip to content

Instantly share code, notes, and snippets.

View desmondmc's full-sized avatar
🐢

Desmond McNamee desmondmc

🐢
View GitHub Profile
@desmondmc
desmondmc / TestViewController.swift
Last active February 3, 2017 18:15
Micro ViewModel+View Recipe RxSwift
class TestViewModel {
struct Inputs {
let tap = PublishSubject<Void>()
}
struct Outputs {
let someString: Observable<String?>
}
let inputs: TestViewModel.Inputs
@desmondmc
desmondmc / RxDelegate.swift
Last active February 4, 2017 12:12
Simple example of replacing the delegate pattern with Observable pattern.
//
// UITextView+Rx.swift
// bodytonic-ios
//
// Created by Desmond McNamee on 2017-02-04.
// Copyright © 2017 Stadium Studio. All rights reserved.
//
import Foundation
import UIKit
@desmondmc
desmondmc / RetainCycle.swift
Created September 15, 2016 09:49
An example of a retain cycle using swift blocks.
//
// ViewController.swift
// RetainCylceTests
//
// Created by Desmond McNamee on 15/09/16.
// Copyright © 2016 Teamplace. All rights reserved.
//
import UIKit
@desmondmc
desmondmc / KeyboardHeight.swift
Created September 14, 2016 13:33
RxSwift wrapper for keyboard height.
//
// KeyboardHeight.swift
// bodytonic-ios
//
// Created by Desmond McNamee on 2016-08-28.
// Copyright © 2016 Stadium Studio. All rights reserved.
//
import UIKit
import RxSwift
@desmondmc
desmondmc / CollectionViewMagic.swift
Last active October 29, 2016 13:16
Super CollectionView/TableView nib loading with protocols and generics.
//
// CollectionViewMagic.swift
// bodytonic-ios
//
// Created by Desmond McNamee on 2016-10-29.
// Copyright © 2016 Stadium Studio. All rights reserved.
//
import UIKit
@desmondmc
desmondmc / Updateable.swift
Last active September 6, 2016 12:59
Updateable Realm Object
extension Updateable where Self: RLMObject {
static func persistJSON(json: NSDictionary) {
let update = Self.partialUpdateDicWithJSON(json)
let realm = RealmPersister.realm
realm.beginWriteTransaction()
Self.createOrUpdateInRealm(realm, withValue: update)
try! realm.commitWriteTransaction()
}
}