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
var initalArray = [1, 2, 3] | |
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray) | |
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count)) |
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
// | |
// KeyboardListener.swift | |
// KeyboardListener | |
// | |
// Created by Jānis Kiršteins on 15/03/15. | |
// Copyright (c) 2015 Jānis Kiršteins. All rights reserved. | |
// | |
import UIKit |
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 class Box<T> { | |
public let value: T | |
public init(_ value: T) { | |
self.value = value | |
} | |
} | |
public enum Result<T> { | |
case Success(Box<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
internal extension Array { | |
internal func get(index: Int) -> Element? { | |
return index >= 0 && index < self.count ? self[index] : nil | |
} | |
internal func at(indexes: [Int]) -> [Element] { | |
var result: [Element] = [] | |
for index in indexes { | |
result.append(self[index]) | |
} |
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
echo -e 'build/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.hmap\n*.ipa\n*.xcuserstate\n.DS_Store\n\nCarthage/Build' > .gitignore |
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
private let drawingCache = NSCache() | |
public extension UIImage { | |
public class func imageForSize(size: CGSize, opaque: Bool = false, drawingBlock: () -> Void) -> UIImage { | |
assert(size != CGSize.zeroSize) | |
UIGraphicsBeginImageContextWithOptions(size, opaque, 0.0) | |
drawingBlock() | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext(); |
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 ObjectiveC | |
import UIKit | |
var associatedObjectHandle: UInt8 = 0 | |
class TextDidChangeHandler: NSObject { | |
unowned let textField: UITextField | |
let handler: (textField: UITextField) -> Void | |
init(textField: UITextField, handler: (textField: UITextField) -> Void) { | |
self.handler = handler |
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
// | |
// ViewController.swift | |
// SendEmailWithAttachment | |
// | |
// Created by Kelly Egan on 3/17/15. | |
// Copyright (c) 2015 Kelly Egan. All rights reserved. | |
// | |
import UIKit | |
import MessageUI |
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
/// Get the top most view controller in presentation chain | |
func topPresentedController() -> UIViewController? { | |
var topPresentedController = rootViewController | |
while let nextTopPresentedController = topPresentedController?.presentedViewController { | |
topPresentedController = nextTopPresentedController | |
} | |
return topPresentedController | |
} |
OlderNewer