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
// UIView+Find.swift | |
// | |
// Copyright (c) 2016 Kaz Yoshikawa. Released under MIT License. | |
extension UIView { | |
func findViewController<T: UIViewController>() -> T? { | |
var responder = self.nextResponder() | |
while responder != nil { | |
if let viewController = responder as? T { |
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
// ZMapTable.swift | |
// | |
// Copyright (c) 2016 Kaz Yoshikawa. Released under MIT License. | |
enum ZMapTableOption { | |
case StrongToWeak | |
case WeakToStrong | |
case WeakToWeak | |
case StrongToStrong | |
} |
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
// | |
// ZCollection.swift | |
// ZKit | |
// | |
// Created by Kaz Yoshikawa on 2015/01/12. | |
// Copyright (c) 2015 Kaz Yoshikawa. All rights reserved. | |
// | |
// This software may be modified and distributed under the terms | |
// of the MIT license. | |
// |
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 UIKit | |
extension UIDevice { | |
class func storyboard(name name: String, bundle: NSBundle? = nil) -> UIStoryboard { | |
let userInterfaceIdiom = UIDevice.currentDevice().userInterfaceIdiom | |
let modifier: String = { | |
switch userInterfaceIdiom { | |
case .Pad: return "~ipad" |
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
// | |
// NSScanner+Z.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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
// | |
// BinaryStringConvertible.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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
// | |
// ZDictionary.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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
// | |
// ZManagedObjectStorage.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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
func synchronized<Result>(lock: NSLock, block: () throws -> Result) rethrows -> Result { | |
lock.lock() | |
defer { lock.unlock() } | |
return try block() | |
} | |
let lock = NSLock() | |
func doThing() { |
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
// | |
// NSFileHandle+Z.swift | |
// ZKit | |
// | |
// Created by Kaz Yoshikawa on 2/18/16. | |
// | |
// | |
import Foundation |