Skip to content

Instantly share code, notes, and snippets.

@zorn
Created January 12, 2016 22:11
Show Gist options
  • Save zorn/a02cebd22dcdfd4478dc to your computer and use it in GitHub Desktop.
Save zorn/a02cebd22dcdfd4478dc to your computer and use it in GitHub Desktop.
private func loadCastData() {
// [
// {
// "title": "April Main Meeting",
// "date": "2016-04-14T18:30:00-0500",
// "rsvp_count": 2,
// "announced": false
// },
// {
// "title": "Febuary Main Meeting",
// "date": "2016-02-11T18:30:00-0500",
// "rsvp_count": 31,
// "announced": true
// },
// {
// "title": "March Main Meeting",
// "date": "2016-03-10T18:30:00-0500",
// "rsvp_count": 4,
// "announced": false
// }
// ]
if let data = getDataFromFileURL(self.dataURL) {
let json: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, options: [])
if let j: AnyObject = json {
let decodedCastMember: Decoded<FireflyCastMember> = decode(j)
switch decodedCastMember {
case .Success(let castMember):
castList.append(castMember)
case .Failure(let error):
presentError(error)
}
}
} else {
presentError("Could not load data file.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment