This is a simple Movie DB client for iPhones written in Swift. I use it mostly to try out new ideas and technologies.
zoul / movies Goto Github PK
View Code? Open in Web Editor NEWA sample Swift iOS client for themoviedb.org
License: MIT License
A sample Swift iOS client for themoviedb.org
License: MIT License
This is a simple Movie DB client for iPhones written in Swift. I use it mostly to try out new ideas and technologies.
I don’t mind parsing the JSON by hand, it’s nicely explicit. What I don’t like is repeating the property names:
guard let dict = jsonObject as? NSDictionary,
let id = dict["id"] as? Int,
let title = dict["title"] as? String,
let voteAverage = dict["vote_average"] as? Float,
let backdropPath = dict["backdrop_path"] as? String,
let overview = dict["overview"] as? String,
let releaseDate = dict["release_date"] as? String
else { return nil }
self.id = id
self.title = title
self.voteAverage = voteAverage
self.backdropPath = backdropPath
self.overview = overview
self.releaseDate = releaseDate
I like what Argo does:
return curry(User.init)
<^> json <| "id"
<*> json <| "name"
<*> json <|? "email" // Use ? for parsing optional values
<*> json <| "role" // Custom types that also conform to Decodable just work
<*> json <| ["company", "name"] // Parse nested objects
<*> json <|| "friends" // parse arrays of objects
The interesting trick is using the Curry module, see the accompanying blog post.
Right now I have to remove the token from the code before committing, which is dumb. It would be nice to store it in an ignored file, for example.
We want to build the code and run the tests. There’s a nice tutorial over at Swift Talks.
See this post by Kickstarter and the video linked from there. The main idea is having the option to tweak all possible state variables interactively in a playground, instead of having to navigate the live UI to get there. Also, this should enable easy screenshot testing, ie. rendering the screens for various state combinations and then checking them against known “good” screenshots.
MovieDetailController
so that it can be loaded in a playgroundMovieListController
so that it can be loaded in a playgroundMovie
, for instance)Right now the caching is probably completely broken. That could be fixed by setting the right caching options when reading from the webservice, but the real goal here is to detect offline mode and set the cache behaviour accordingly (.useProtocolCachePolicy
when online, .returnCacheDataDontLoad
when offline?).
Right now we simply accept the string returned by the server.
Right now there’s always an asynchronous call with a placeholder image even if the real image is cached. It would be nice to load the cached images immediately.
Right now the errors are just logged, if even that.
See the developer docs regarding images, the current implementation hardcodes a simplified version of the API.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.