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
// | |
// ZoomableImageView.swift | |
// ZoomableImage | |
// | |
// Created by Nuno Gonçalves on 01/04/17. | |
// Copyright © 2017 Nuno Gonçalves. All rights reserved. | |
// | |
import UIKit |
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 | |
enum VehicleType : RawRepresentable { | |
struct Vehicle : Equatable { | |
let name: String | |
let wheels: Int |
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
//See the bottom of this file to check what you can do with this | |
let calendar = Calendar(identifier: .gregorian) | |
struct CalendarComponentAmount { | |
let component: Calendar.Component | |
let amount: Int | |
} | |
infix operator +: AdditionPrecedence |
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
// | |
// DatePicker.swift | |
// CreditCard | |
// | |
// Created by Nuno Gonçalves on 13/11/16. | |
// Copyright © 2016 Nuno Gonçalves. All rights reserved. | |
// | |
import UIKit |
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 | |
import PlaygroundSupport | |
//http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number | |
enum CreditCardType { | |
case visa | |
case visaElectron | |
case mastercard |
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
protocol Requestable { | |
associatedtype Element | |
var httpMethod: HTTPMethod { get } | |
var headers: HeadParams? { get } | |
var bodyParams: BodyParams? { get } | |
var encoding: RequestEncoding { get } | |
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
protocol Deserializable { | |
associatedtype T: Deserializer | |
var deserializer: T { get } | |
func getDataFrom(dictionary: NSDictionary) -> T.MappedObject | |
} | |
extension Deserializable { | |
func getDataFrom(dictionary: NSDictionary) -> T.MappedObject { | |
return deserializer.buildFrom(dictionary) |
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 Users { | |
class Getter : Requestable, WebGetter, Authenticable, EmptyBody, UrlEncodable, Deserializable { | |
var deserializer = Deserialize.UserDeserializer() | |
var url = "https://..." | |
func getUserDetails(success success: User -> (), failure: ApiResponse -> ()) { | |
call(success: success, failure: failure) | |
} | |
} |
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
protocol Authenticable { | |
var headers: HeadParams? { | |
get | |
} | |
func fillHeaders() | |
} | |
extension Authenticable { | |
var headers: HeadParams? { |
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 Users { | |
class Getter : Requestable { | |
var httpMethod = HTTPMethod.GET | |
var headers: HeadParams? = ["Authorization" : "Bearer \(CurrentUser.accessToken ?? "")"] | |
func fillHeaders() {} | |
var bodyParams: BodyParams? = [:] | |
func fillBodyParams() {} | |