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 NSURL { | |
convenience init(string: String, query: Dictionary<String, String>?) { | |
if query == nil { | |
self.init(string: string)! | |
return | |
} | |
let components = NSURLComponents(string: string) | |
var querryItems = components?.queryItems ?? Array<NSURLQueryItem>() | |
query?.forEach() { | |
querryItems.append(NSURLQueryItem(name: $0.0, value: $0.1)) |
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 | |
public class Tree<Element> { | |
public var parent: Tree<Element>? | |
public let value: Element | |
public let children: [Tree<Element>]? | |
init(withParent parent: Tree<Element>? = nil,value: Element,children: [Tree<Element>]? = nil) { | |
self.parent = parent | |
self.children = children |
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 | |
public extension String { | |
var localized: String { | |
return LocalizationManager.sharedInstance.getTranslation(forText: self) ?? self | |
} | |
} | |
class LocalizationManager { | |
static let sharedInstance = LocalizationManager() |
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
// | |
// EventEmitter.swift | |
// Mooovy | |
// | |
// Created by Gujgiczer Máté on 08/02/16. | |
// Ispired by Balázs Schwarzkopf | |
// Copyright © 2016 Mooovy. All rights reserved. | |
// | |
import Foundation |
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
// | |
// API.swift | |
// | |
// Created by Gujgiczer Máté on 19/03/16. | |
// | |
import Foundation | |
public enum APIError: Int, ErrorType { | |
case Unknown |
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
public extension Array where Element: Equatable { | |
func find(other: Element) -> Element? { | |
for element in self { | |
if element == other { | |
return element | |
} | |
} | |
return nil | |
} |
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
static func uploadData(endpoint: NSURL, binaryData: NSData, | |
boundary: String = "defaultBoundary", data: Dictionary<String, AnyObject>? = nil, done: ((NSError?, JSON) -> Void)? = nil) | |
{ | |
// create url request to send | |
let mutableURLRequest = NSMutableURLRequest(URL: endpoint) | |
mutableURLRequest.HTTPMethod = "PUT" | |
let boundaryConstant = boundary; | |
let contentType = "multipart/form-data;boundary="+boundaryConstant | |
mutableURLRequest.setValue(contentType, forHTTPHeaderField: "Content-Type") |
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 | |
protocol ExcutableQueue { | |
var queue: dispatch_queue_t { get } | |
} | |
extension ExcutableQueue { | |
func execute(closure: () -> Void) { | |
dispatch_async(queue, closure) | |
} |
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 Range: IntegerLiteralConvertible { | |
public init(integerLiteral value: Int) { | |
self = (value as! Element).rangeValue | |
} | |
} | |
extension ForwardIndexType { | |
var rangeValue: Range<Self> { |
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
public protocol OptionalValueObservable { | |
var isComplete: Bool {get} | |
var hasAnyProperty: Bool {get} | |
} | |
public extension OptionalValueObservable { | |
var isComplete: Bool { | |
get { | |
return Mirror(reflecting: self).children.reduce(true) { acc, val in | |
let subMirror = Mirror(reflecting: val.value) |
OlderNewer