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 Foundation | |
func += <KeyType, ValueType> (inout left: Dictionary<KeyType, ValueType>, right: Dictionary<KeyType, ValueType>) { | |
for (k, v) in right { | |
left.updateValue(v, forKey: k) | |
} | |
} |
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 UIKit | |
extension UIImage { | |
public class func imageWithScreenshotFromView(view: UIView) -> UIImage! { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.mainScreen().scale) | |
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) | |
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} |
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 Foundation | |
protocol Validator { | |
func validateWithError(error: NSErrorPointer) -> Bool | |
} | |
/////////////////////////////////////////////// | |
// MARK: - PasswordValidator - | |
/////////////////////////////////////////////// | |
class PasswordValidator: Validator { | |
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 UIKit | |
extension UIColor { | |
class func customGrayColor() -> UIColor { | |
let r: CGFloat = CGFloat(41.0/255.0) | |
let g: CGFloat = CGFloat(41.0/255.0) | |
let b: CGFloat = CGFloat(41.0/255.0) | |
return UIColor(red: r, green: g, blue: b, alpha: 1.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
import Foundation | |
private var sDateFormatter: NSDateFormatter = NSDateFormatter() | |
extension NSDate | |
{ | |
convenience | |
init?(fromDateString dateString: String) { | |
sDateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" | |
sDateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 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
import Foundation | |
extension NSNumber | |
{ | |
var timeIntervalValue: NSTimeInterval { | |
get { | |
return (self.doubleValue as NSTimeInterval) | |
} | |
// TODO: write a setter | |
} |
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 UIKit | |
extension UIColor { | |
class func colorWithComponents(red redComponent: Float, green: Float, blue: Float, alpha: Float) -> UIColor { | |
let r: CGFloat = CGFloat(redComponent/255.0) | |
let g: CGFloat = CGFloat(green/255.0) | |
let b: CGFloat = CGFloat(blue/255.0) | |
let a: CGFloat = CGFloat(alpha) | |
return UIColor(red: r, green: g, blue: b, alpha: a) |
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 UIKit | |
enum MPSTableViewCellSeparator { | |
case Default, None | |
// returns views for each style - very convinient | |
func view() -> UIView? { | |
switch (self) { | |
case .None: | |
return nil |
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 Foundation | |
class UBINullableSortDescriptor: NSSortDescriptor { | |
override init(key: String, ascending: Bool) { | |
super.init(key: key, ascending: ascending) | |
} | |
required override init(key: String, ascending: Bool, selector: Selector) { | |
super.init(key: key, ascending: ascending, selector: selector) |
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 <Foundation/Foundation.h> | |
@interface NSString (URLValidation) | |
- (BOOL)isValidURL; | |
@end |
OlderNewer