1

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.

jorjj
  • 85
  • 2
  • 12
  • see, How to load GIF in swift : http://stackoverflow.com/questions/27919620/how-to-load-gif-image-in-swift/27922518#27922518 – Kirit Modi Jan 17 '17 at 05:50

1 Answers1

0

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

Community
  • 1
  • 1
nathangitter
  • 9,607
  • 3
  • 33
  • 42
  • thanks! I'll check everything you sent to me. But I have a question. The last link includes for the images, but I want to use gif. So if I change the type as a gif, do you thing that's gonna work? – jorjj Jan 17 '17 at 02:21
  • 1
    Here's a Stack Overflow answer about downloading gifs specifically: http://stackoverflow.com/a/27922518/6658553 – nathangitter Jan 17 '17 at 02:26
  • If my answer solved your problem, feel free to mark it as accepted so others in the future can benefit as well. – nathangitter Jan 17 '17 at 02:28
  • I checked the last link and the framework for gifs is old and not working for swift 3. – jorjj Jan 17 '17 at 02:41
  • I would probably post a comment on the answer to see if there's an updated version, or post a new question about it. – nathangitter Jan 17 '17 at 03:14