Skip to content

Instantly share code, notes, and snippets.

@burin
Last active August 29, 2015 14:17
Show Gist options
  • Save burin/64fdff4b0d8095ab65a9 to your computer and use it in GitHub Desktop.
Save burin/64fdff4b0d8095ab65a9 to your computer and use it in GitHub Desktop.
How do i organize swift "utility" functions?
extension String {
func asTripDictionary() -> NSDictionary {
return ["wat":"wat"]
}
}
extension NSDate {
func asLocalISOString() -> String {
return "2015-03-12T13:24:00"
}
}
var tripData2: NSDictionary = json.asTripDictionary()
var dateString2: String = NSDate().asLocalISOString()
class TripUtils {
class func parseJSON(json: String) -> NSDictionary {
return ["wat":"wat"]
}
}
class DateUtils {
class func localISOStringFromDate(date: NSDate) -> String {
return "2015-03-12T13:24:00"
}
}
var json = "{\"haha\": \"haha\"}"
var tripData: NSDictionary = TripUtils.parseJSON(json)
var dateString: String = DateUtils.localISOStringFromDate(NSDate())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment