Skip to content

Instantly share code, notes, and snippets.

@tranhieutt
Created July 12, 2017 09:19
Show Gist options
  • Save tranhieutt/7d9730f387e7ea9483200f61977dfeae to your computer and use it in GitHub Desktop.
Save tranhieutt/7d9730f387e7ea9483200f61977dfeae to your computer and use it in GitHub Desktop.
SOLID - S
class Handler {
func handle() {
let data = requestDataToAPI()
let array = parse(data: data)
saveToDB(array:array)
}
private func requestDataToAPI() -> Data {
//send API request and wait the response
}
private func parse(data: Data) -> [String] {
//parse data and create the array
}
private func saveToDB(array: [String]) {
//save the array in a database (CoreData, Realm)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment