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 AVFoundation | |
| class EACAudioManager: NSObject { | |
| static let sharedInstance = EACAudioManager() | |
| var volumeDidChange = { (newVolume: Float) -> () in } | |
| var currentVolume: Float { return AVAudioSession.sharedInstance().outputVolume } | |
| override init() { | |
| super.init() | |
| try! AVAudioSession.sharedInstance().setActive(true) | |
| AVAudioSession.sharedInstance().addObserver(self, forKeyPath: "outputVolume", options: NSKeyValueObservingOptions.New, context: nil) |
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 UIStoryboard { | |
| func instantiateViewControllerWithTypeAsIdentifier<T>(t: T.Type) -> T { | |
| return instantiateViewControllerWithIdentifier(String(t)) as! T | |
| } | |
| } |
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 | |
| import XCPlayground | |
| class ClickableLinkTextView: UITextView { | |
| override init(frame: CGRect, textContainer: NSTextContainer?) { | |
| super.init(frame: frame, textContainer: textContainer) | |
| setUp() | |
| } | |
| required init?(coder aDecoder: NSCoder) { |
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 | |
| /** | |
| You can use this to initalize an object (class or struct) while containing the set up code for it in a block | |
| */ | |
| @warn_unused_result | |
| func setUpObject<T>(obj: T, withBlock setUp: (inout T) -> ()) -> T { | |
| var _obj = obj | |
| setUp(&_obj) | |
| return _obj |
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
| UIView *getStatusBar() { | |
| UIView *subViewWindow = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; | |
| for (UIView *i in subViewWindow.subviews) { | |
| if ([i isKindOfClass:NSClassFromString(@"UIStatusBar")]) { | |
| return i; | |
| } | |
| } | |
| return nil; | |
| } |
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 |
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
| 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
| 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 MyTableViewCell: UITableViewCell { | |
| @IBOutlet var switchview: UISwitch! | |
| @IBOutlet var sliderview: UISlider! | |
| } | |
| class Section { | |
| var count: Int { return cells.count } |
OlderNewer