I found some framework which namely Giphy Client, to use the Giphy's gifs easily. But there is no tutorial on how to use it. Sorry for this rookie question. Can someone explain me to how can I search the gifs and get them with using this client?
Here is the gif search function :
func test(){
let gif1 = Giphy(apiKey: "dc6zaTOxFJmzC")
gif1.search("lol", limit: nil, offset: nil, rating: nil) { (gifs, pagination, err) in
}
}
I really don't know what's in the gifs
value and I'm struggling because of that. There is a lot of subclass like url, id or rankings, but I can't figured it out.
All the information is available on the GitHub page you linked in your question. To find more about the gifs
variable, you can use Xcode's Utilities menu (the right side bar) to see documentation when you click on a variable or function.
Alternatively, you can jump to the definition of a variable by holding command and clicking it. The information about the Gif
object is available here on GitHub as well.
It looks like the gifs
variable is an optional array of Gif
objects (its type is [Gif]?
).
The Gif
object has some useful properties like id
, rating
, and giphyURL
(a URL
pointing to the actual gif image).
Since you most likely want to get the images themselves, you can make network requests to get the actual image data. This has already been covered extensively on Stack Overflow. Here is an answer to get you started with getting image data from a url: https://stackoverflow.com/a/27712427/6658553