I was recently tasked with learning about custom transition and parsing JSON in Swift 4 (my mind was blown by the information I found out about the latter).
I created a mini app with my newfound knowledge, but I wanted to briefly discuss what I've learned.
Custom transitions are made possible by a group of protocols, and there's a sequence to these protocols. It starts with the transitioning delegate (a view controller that the developer assigns - HomePageViewController in my project) which provides the developer with the animation controller (that you need to create - CustomPresentAnimationController in my project) whenever a view controller is presented. The animation controller controls the transition since it handles the logic of the animation for the views (the two functions in the controller handle the duration and actions of the animation). Another important portion for custom transitioning context, it is passed to the animation controller when the transition occurs and holds the info about the views involved in the transition.
Parsing JSON in Swift 4:
Aw man, where to begin. It's been awhile since I've dealt with JSON, but bringing my attention back to JSON and discovering Codable has been damn exciting! I was able to parse JSON with two small structs (RandomPhoto and ImageURL struct in my project ).
Codable is actually a combination of the Encodable and Decodable protocols. I only needed to decode/parse my JSON so I stuck with using the Decodable protocol for my structs. Okay, I'm over-simplifying, there's more to it than that. JSONDecoder for example - which decodes the data received from the network call. Also, the decode function that returns the value of the type that's specified (RandomPhoto in the case of the app I created), decoded from a JSON object.
It was fun looking into and implementing new (to me) Swift features. Wondering what I should dig into next.