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
// A Twitter guy requested a way to update all his contacts family names to be uppercased | |
// So, I wanted to give a try to the all new iOS 9 Contacts framework | |
// I'm a Swift noob, I didn't even finish reading the Swift book (I'm at p. 302 :D) | |
import Contacts | |
let store = CNContactStore() | |
store.requestAccessForEntityType(.Contacts) { success, formerError in |
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
// Creates a UIColor from a Hex string. | |
func colorWithHexString (hex:String) -> UIColor { | |
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString | |
if (cString.hasPrefix("#")) { | |
cString = cString.substringFromIndex(1) | |
} | |
if (countElements(cString) != 6) { | |
return UIColor.grayColor() |