This file contains hidden or 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 | |
| protocol Initializer {} | |
| extension Initializer { | |
| func with(bootStrap: (inout Self) -> ()) -> Self { | |
| var s = self | |
| bootStrap(&s) | |
| return s | |
| } | |
| } |
This file contains hidden or 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
| class UISearchBarMagnifyingGlass: NSObject { | |
| @IBOutlet weak var searchBar: UISearchBar! { | |
| didSet { | |
| if let _color = color, let _searchBar = searchBar { | |
| for i in _searchBar.subviews.first!.subviews { | |
| if let textField = i as? UITextField, | |
| let imageView = textField.leftView as? UIImageView, | |
| let image = imageView.image | |
| { | |
| let coloredImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) |
This file contains hidden or 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 UISearchBar { | |
| /** An easy way to set the magnifying glass color in interface builder | |
| It is recommended to set this in interface Builder, | |
| However if you want to do it programatically you can do it like this: | |
| ``` | |
| let searchBar = UISearchBar() | |
| searchBar.magnifyingGlassColor = UIColor.red | |
| ``` | |
| */ | |
| @IBInspectable var magnifyingGlassColor: UIColor { |
This file contains hidden or 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 supportsKeyboard(lang: String?) -> Bool { | |
| guard let _lang = lang else { | |
| return false | |
| } | |
| let predicates = [ | |
| Predicate(format: "SELF == %@", "en"), | |
| Predicate(format: "SELF like[cd] %@", "en-*") | |
| ] | |
| for predicate in predicates { | |
| if NSArray(arrayLiteral: _lang).filtered(using: predicate).count > 0 { |
This file contains hidden or 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 | |
| class MyTableViewCell: UITableViewCell { | |
| @IBOutlet var switchview: UISwitch! | |
| @IBOutlet var sliderview: UISlider! | |
| } | |
| class Section { | |
| var count: Int { return cells.count } |
This file contains hidden or 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
| protocol Singleton3_Protocol { | |
| static var queue: OperationQueue { get } | |
| static func method1() | |
| } | |
| protocol Name { | |
| static var name: String { get set } | |
| } | |
| protocol Singleton3_Protocol2: Name { |
This file contains hidden or 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 | |
| class Singleton { | |
| class func sharedInstance() -> Singleton { | |
| struct __ { static let _sharedInstance = Singleton() } | |
| return __._sharedInstance | |
| } | |
| var name: String = String() | |
| } |
This file contains hidden or 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 | |
| /** | |
| original macro | |
| #define DHLocalizedString(KEY, TABLE, COMMENT) NSLocalizedStringWithDefaultValue(KEY, TABLE, [NSBundle mainBundle], NSLocalizedStringWithDefaultValue(KEY, TABLE, [NSBundle bundleForClass:[self class]]), COMMENT) | |
| */ | |
| func getNameByRemovingPrefixPathAndExtension(name: String) -> String { | |
| let url = NSURL(string: name)! |
This file contains hidden or 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
| // Making a class since we can not add generics to UIStoryboard nor can we make a category for it. | |
| @interface UIStoryboardHelper <__covariant T:UIViewController *> : UIStoryboard | |
| - (T)vcFromIdentifier:(NSString *)identifier fromStoryboard:(UIStoryboard *)storyboard; | |
| @end | |
| @implementation UIStoryboardHelper | |
| - (UIViewController *)vcFromIdentifier:(NSString *)identifier fromStoryboard:(UIStoryboard *)storyboard { | |
| return [storyboard instantiateViewControllerWithIdentifier:identifier]; | |
| } | |
| @end |