April 2015
Intermediate to advanced
556 pages
17h 47m
English
Congratulations, it works! But are you finished? Your application already detects errors from JSON parsing (converting the received JSON data into a tree of NSDictionary, NSArray, and so forth), but it does not check that the structure of this data satisfies the expectations of the app’s code.
As it stands, the code makes some assumptions about the structure of the JSON. Consider these lines:
let title = courseDict["title"] as! String
let urlString = courseDict["url"] as! String
let upcomingArray = courseDict["upcoming"] as! [NSDictionary]
let nextUpcomingDict = upcomingArray.first!
let nextStartDateString = nextUpcomingDict["start_date"] as! String
This code makes several assumptions: ...
Read now
Unlock full access