Skip to content

Instantly share code, notes, and snippets.

View csfelipe's full-sized avatar
🍀
It's all good

Felipe C. csfelipe

🍀
It's all good
View GitHub Profile
@McNight
McNight / Contacts.swift
Last active November 27, 2015 11:02
Uppercase all contacts family names
// 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
@shadcn
shadcn / gist:de147c42d7b3063ef7bc
Last active September 17, 2022 11:50
Convert a Hex string to UIColor in Swift
// 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()