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 colorFromRGB( #r: Int, g: Int, b: Int ) -> UIColor | |
{ | |
return UIColor( red: CGFloat(r) / 255.0, green: CGFloat(g) / 255.0, blue: CGFloat(b) / 255.0, alpha: CGFloat(1.0) ) | |
} | |
class func brandColor() -> UIColor |
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
self.yourImageView.image = [self.yourImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | |
self.yourImageView.tintColor = [UIColor yourColor]; |
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 let alertController: AnyClass = NSClassFromString( "UIAlertController" ) | |
{ | |
// iOS 8: use UIAlertController | |
let alert = UIAlertController( title: "", message: "", preferredStyle: .Alert ) | |
alert.addAction( UIAlertAction( title: "OK", style: .Default, handler: nil )) | |
presentViewController( alert, animated: true, completion: nil ) | |
} | |
else | |
{ | |
// iOS 7: use UIAlertView |
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
func isValidEmail(testStr:String) -> Bool | |
{ | |
let emailRegEx = ".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*" | |
var emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx) | |
return emailTest!.evaluateWithObject(testStr) | |
} |
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
extension Array | |
{ | |
mutating func removeObject<U: Equatable>(object: U) { | |
var index: Int? | |
for (idx, objectToCompare) in enumerate(self) { | |
if let to = objectToCompare as? U { | |
if object == to { | |
index = idx | |
} | |
} |
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
func distinct<T: Equatable>( source: [T] ) -> [T] | |
{ | |
var unique = [T]() | |
for item in source | |
{ | |
if !contains( unique, item ) { | |
unique.append( item ) | |
} | |
} | |
return unique |