public func getPokemonEnglishDescription(with name: String, callback: @escaping ((String)->()))
public func getShakespeareanDescription(with name: String, callback:@escaping ((String)->()))
public func getPokemonSprites(with name: String, callback: @escaping ((PokemonResource?)->()))
Clone the repository and open PokemonToShakespeareanKit.xcodeproj
and command + b build.
There will build a PokemonToShakespeareanKit.framework for ios.
Add this framework to your project.
Then import PokemonToShakespeareanKit to your code
import PokemonToShakespeareanKit
Then use the functions. For example
getShakespeareanDescription(with: name) {[weak self] (description) in
guard let self = self else {return}
DispatchQueue.main.async {
self.label.text = description
}
}
getPokemonSprites(with: name) {[weak self] (result) in
guard let self = self else {return}
if let pokemon = result {
DispatchQueue.main.async {
self.imageView1.downloaded(from: pokemon.sprites.frontDefault)
self.imageView2.downloaded(from: pokemon.sprites.backDefault)
self.imageView3.downloaded(from: pokemon.sprites.frontShiny)
self.imageView4.downloaded(from: pokemon.sprites.backShiny)
}
}
}
Take a look at the full example in PokemonToShakespeareanApp.
Open PokemonToShackspeare.xcworkspace.
Select PokemonToShakespeareanApp scheme.
Command + r run the app.
Open PokemonToShakespeareanKit.xcodeproj
and command + u start test.
Tests will pass in first 5 times.
When achieve Shakespeare translator API request limied. 5 request / hour.
Tests will fail. (lol)
let name = text.lowercased()