Skip to content

Instantly share code, notes, and snippets.

View thii's full-sized avatar

Thi Doan thii

View GitHub Profile
extension NSUUID {
public class func shortUUID() -> String {
let uuid = NSUUID().UUIDString
let indexOfDash = uuid.rangeOfString("-")!.startIndex
return uuid.substringToIndex(indexOfDash)
}
}
@thii
thii / AppVersion.swift
Created March 13, 2016 10:10
Safe way to get current app version and build
import Foundation
struct AppVersion {
static func version() -> String? {
return NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String
}
static func build() -> String? {
return NSBundle.mainBundle().infoDictionary?["CFBundleVersion"] as? String
}
import Alamofire
import SwiftyJSON
extension Request {
public static func SwiftyJSONResponseSerializer(
options options: NSJSONReadingOptions = .AllowFragments)
-> ResponseSerializer<JSON, NSError>
{
return ResponseSerializer { _, _, data, error in
guard error == nil else { return .Failure(error!) }
import UIKit
class DismissSegue: UIStoryboardSegue {
override func perform() {
let sourceViewController = self.sourceViewController as UIViewController
sourceViewController.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
}
}