This file contains hidden or 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 String { | |
init?(utf16chars:[UInt16]) { | |
var str = "" | |
var generator = utf16chars.generate() | |
var utf16 : UTF16 = UTF16() | |
var done = false | |
while !done { | |
let result = utf16.decode(&generator) | |
switch result { |
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
struct Domino { | |
let left: Int | |
let right: Int | |
init(string: String) { | |
let split = string.componentsSeparatedByString("-") |
This file contains hidden or 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 | |
struct Domino { | |
let left: Int | |
let right: Int | |
init(string: String) { | |
let split = string.componentsSeparatedByString("-") | |
left = split.first.flatMap { Int($0) } ?? 0 | |
right = split.last.flatMap { Int($0) } ?? 0 |
This file contains hidden or 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 | |
import RxSwift | |
import Result | |
extension ObservableType where E: ResultType { | |
func doOnSuccess(onSuccess: (E.Value throws -> Void)) | |
-> Observable<E> { | |
return self.doOnNext { (value) in | |
guard let successValue = value.value else { |
This file contains hidden or 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
// | |
// DressDetailsAddToBagViewModel.swift | |
// ChicByChoice | |
// | |
// Created by Francisco Gonçalves on 19/02/16. | |
// Copyright © 2016 Chic by Choice. All rights reserved. | |
// | |
import Foundation | |
import RxSwift |
This file contains hidden or 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
// | |
// DressDetailsAddToBagViewModel.swift | |
// ChicByChoice | |
// | |
// Created by Ivan Bruel on 18/04/16. | |
// Copyright © 2016 Chic by Choice. All rights reserved. | |
// | |
import Foundation | |
import RxSwift |
This file contains hidden or 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
class AnimalTableViewCell: UITableViewCell { | |
private var imageView: UIImageView | |
private var nameLabel: UILabel | |
private var hungryIconView: HungryIconView | |
private let disposeBag = DisposeBag() | |
var viewModel: AnimalViewModel { | |
didSet { |
This file contains hidden or 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
class AnimalViewModel { | |
let name: String | |
let image: UIImage | |
private let _hungry: Variable<Bool> | |
var hungry: Observable<Bool> { | |
return _hungry.asObservable() | |
} | |
init(animal: Animal) { |
This file contains hidden or 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
class AnimalViewController: UIViewController { | |
// Model Object | |
var animal: Animal | |
// View Object | |
var imageView: UIImageView | |
override func viewDidLoad() { | |
// Maps Model into a View |
This file contains hidden or 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
class Animal { | |
var name: String | |
var age: Int | |
var image: UIImage | |
init(name: String, age: Int, image: UIImage) { | |
self.name = name | |
self.age = age | |
self.image = image | |
} |