Last active
August 29, 2015 14:17
-
-
Save burin/64fdff4b0d8095ab65a9 to your computer and use it in GitHub Desktop.
How do i organize swift "utility" functions?
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 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() |
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
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