I've moved this gist to https://github.com/phynet/iOS-Schemes please check it there ;)
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
// Option without self | |
class Foo1 { | |
private let controller: UIViewController = { | |
return UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()! | |
}() | |
private lazy var window: UIWindow = { | |
let window = UIWindow(frame: UIScreen.mainScreen().bounds) | |
window.backgroundColor = UIColor.whiteColor() | |
window.makeKeyAndVisible() |
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
// | |
// RN3DTouchGestureRecognizer.swift | |
// | |
// Created by Ryan Nystrom on 10/10/15. | |
// Copyright © 2015 Ryan Nystrom. All rights reserved. | |
// | |
import UIKit.UIGestureRecognizerSubclass | |
class RN3DTouchGestureRecognizer: UIGestureRecognizer { |
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
let color = "blue" | |
let num = 42 | |
localized("Colorless green ideas sleep furiously.") | |
localized("Colorless \(color) ideas sleep furiously.") | |
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.") |
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
// If we extend UnicodeScalar to conform to ForwardIndexType, we can create and map a Range. | |
extension UnicodeScalar: ForwardIndexType { | |
public func successor() -> UnicodeScalar { | |
return UnicodeScalar(value + 1) | |
} | |
} | |
let alphabet = ("A"..."Z" as Range).map { String($0) } | |
// ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] |
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
// CONSTRUCTING ALPHABET ARRAY | |
// This my favorite because it's easily used with any character set | |
extension NSCharacterSet { | |
var members: [String] { | |
let unichars = Array(unichar(0)..<unichar(128)).filter({self.characterIsMember($0)}) | |
return unichars.map({String(UnicodeScalar($0))}) | |
} | |
} |
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
/** | |
* The following preprocessor macros can be used to adopt the new nullability annotations and generics | |
* features available in Xcode 7, while maintaining backwards compatibility with earlier versions of | |
* Xcode that do not support these features. | |
*/ | |
#if __has_feature(nullability) | |
# define __ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN | |
# define __ASSUME_NONNULL_END NS_ASSUME_NONNULL_END | |
# define __NULLABLE nullable |
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
@implementation UIClassSwapper | |
- (instancetype) initWithCoder:(UINibDecoder *)decoder | |
{ | |
NSString *className = [decoder decodeObjectForKey:@"UIClassName"]; | |
NSString *originalClassName = [decoder decodeObjectForKey:@"UIOriginalClassName"]; | |
Class class = NSClassFromString(className); | |
Class originalClass = NSClassFromString(originalClassName); | |
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
// Need both of these, since one `adaptivePresentationStyleForPresentationController:` works on 8.0 to 8.2, and the other, | |
// `adaptivePresentationStyleForPresentationController:traitCollection:` works on 8.3 plus | |
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { | |
return UIModalPresentationNone; | |
} | |
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection { | |
return UIModalPresentationNone; | |
} |
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
// | |
// AppDelegate.swift | |
// TypedTableViewControllers | |
// | |
// Created by Chris Eidhof on 23/03/15. | |
// Copyright (c) 2015 Unsigned Integer. All rights reserved. | |
// | |
import UIKit |