π―
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 mergeAPICall() { | |
| let group = dispatch_group_create() | |
| dispatch_group_enter(group) | |
| /*** | |
| Call your method for each endpoint after dispatch_group_enter(group) | |
| */ | |
| func fetchEventList(success: { (eventList) in | |
| /*** | |
| Add dispatch_group_leave(group) if API Call return success or error |
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 UITableViewCell { | |
| class func nib() -> UINib { | |
| let name = NSStringFromClass(self).componentsSeparatedByString(".").last! | |
| return UINib(nibName: name, bundle: nil) | |
| } | |
| var parentTsableView: UITableView? { | |
| get { | |
| var table: UIView? = superview |
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 UILabel { | |
| func getEstimatedHeight(width: CGFloat) -> CGFloat { | |
| guard let text = self.text else { return CGFloat.min } | |
| var maxHeight = CGFloat.max | |
| if (self.numberOfLines > 0) { | |
| maxHeight = (ceil(self.font.lineHeight) * CGFloat(self.numberOfLines)) | |
| } | |
| let maxSize = CGSizeMake(width, maxHeight) |
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 UIView { | |
| func addConstarintsWithFormat(format: String, views: UIView...) { | |
| var viewsDictionary = [ String : UIView ]() | |
| for (index, view) in views.enumerate() { | |
| let key = "v\(index)" | |
| viewsDictionary[key] = view | |
| view.translatesAutoresizingMaskIntoConstraints = false | |
| } | |
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 UIColor { | |
| public convenience init(hex: String) { | |
| let characterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet().mutableCopy() as! NSMutableCharacterSet | |
| characterSet.formUnionWithCharacterSet(NSCharacterSet(charactersInString: "#")) | |
| let cString = hex.stringByTrimmingCharactersInSet(characterSet).uppercaseString | |
| if (cString.characters.count != 6) { | |
| self.init(white: 1.0, alpha: 1.0) | |
| } else { | |
| var rgbValue: UInt32 = 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
| class GetJSONLocalFile { | |
| class func fromFile(fileName: String) -> String? { | |
| guard let path: String = NSBundle.mainBundle().pathForResource(fileName, ofType: "json") else { | |
| print("Error!, Unable to load \(fileName).json") | |
| return nil | |
| } | |
| do { | |
| guard let data: String = try String(contentsOfFile: path) else { | |
| 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
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view, typically from a nib. | |
| let urlPath = "http://telize.com/geoip" | |
| let url = NSURL(string: urlPath) | |
| let session = NSURLSession.sharedSession() | |
| let task = session.dataTaskWithURL(url!, completionHandler: {data, response, error -> Void in | |
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 String { | |
| func toDate(format: String) -> NSDate? { | |
| let dateFormatter = NSDateFormatter() | |
| dateFormatter.dateFormat = format | |
| return dateFormatter.dateFromString(self) | |
| } | |
| } | |
| extension NSDate { | |
| func toString(format: 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
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
| // Override point for customization after application launch. | |
| let window = UIWindow(frame: UIScreen.mainScreen().bounds) | |
| window.backgroundColor = UIColor.whiteColor() | |
| window.makeKeyAndVisible() | |
| self.window = window | |
| let vc = UIViewController() | |
| let nc = UINavigationController(rootViewController:vc) | |
| window.rootViewController = nc |
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 Array { | |
| func forEach(f: (element: T) -> Void) { | |
| for e in self { | |
| f(element: e) | |
| } | |
| } | |
| } |
OlderNewer