Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heyalexchoi/Giphy-iOS
Giphy API client for iOS in Objective-C
https://github.com/heyalexchoi/Giphy-iOS
Last synced: 7 days ago
JSON representation
Giphy API client for iOS in Objective-C
- Host: GitHub
- URL: https://github.com/heyalexchoi/Giphy-iOS
- Owner: heyalexchoi
- License: mit
- Created: 2014-08-18T19:57:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-07T22:24:27.000Z (almost 8 years ago)
- Last Synced: 2024-04-29T17:06:26.380Z (8 months ago)
- Language: Objective-C
- Homepage:
- Size: 2.41 MB
- Stars: 52
- Watchers: 4
- Forks: 61
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - Giphy - C. (SDK / Unofficial)
- awesome-ios-cn - 官网
- awesome-ios-star - Giphy - C. (SDK / Unofficial)
README
# Giphy-iOS
[![Version](https://img.shields.io/cocoapods/v/Giphy-iOS.svg?style=flat)](http://cocoadocs.org/docsets/Giphy-iOS)
[![License](https://img.shields.io/cocoapods/l/Giphy-iOS.svg?style=flat)](http://cocoadocs.org/docsets/Giphy-iOS)
[![Platform](https://img.shields.io/cocoapods/p/Giphy-iOS.svg?style=flat)](http://cocoadocs.org/docsets/Giphy-iOS)Giphy-iOS is a [Giphy API](https://github.com/Giphy/GiphyAPI) client for iOS in Objective-C.
## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
You should read about [Giphy's Access and API keys here](https://github.com/Giphy/GiphyAPI#access-and-api-keys).
### Giphy-iOS / AXCGiphy
'AXCGiphy' provides convenient access to [Giphy's API](https://github.com/Giphy/GiphyAPI) endpoints:- search
- trending
- translate
- GIF by ID
- GIFs by IDsYou can query the endpoints through the blocks based interface:
```objective-c
- (void)viewDidLoad
{
[super viewDidLoad];
// set your API key before making any requests. You may use kGiphyPublicAPIKey for development.
[AXCGiphy setGiphyAPIKey:kGiphyPublicAPIKey];[AXCGiphy searchGiphyWithTerm:@"frogs" limit:10 offset:0 completion:^(NSArray *results, NSError *error) {
self.giphyResults = results;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.collectionView reloadData];
}];
}];
}- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
AXCCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellIdentifier forIndexPath:indexPath];
AXCGiphy * gif = self.giphyResults[indexPath.item];
NSURLRequest * request = [NSURLRequest requestWithURL:gif.originalImage.url];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
UIImage * image = [UIImage imageWithData:data];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
cell.imageView.image = image;
}];
}] resume];
return cell;
}```
AXCGiphy blocks based class methods provide asynchronous access to either AXCGiphy instances or an NSArray of AXCGiphy instances. AXCGiphy instances represent Giphy's gifs and their metadata. However, AXCGiphy only provides URLs to gifs. How you use these URLs is up to you.
My example uses NSURLRequests with NSURLSession to fetch the image data at the URLs and [mattt's AnimatedGifSerialization](https://github.com/mattt/AnimatedGIFImageSerialization) to decode the animated GIFs into animated UIImages. If you are unsure of how to proceed, use my example app as a starting point.
The blocks based class methods return NSURLSessionDataTasks for additional control, should you need it.
AXCGiphy also provides class methods to generate NSURLRequests for these endpoints.
## Requirements
AFNetworking/Serialization 2.3.1
## Installation
Giphy-iOS is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:pod "Giphy-iOS"
pod 'AFNetworking/Serialization', '~> 2.3.1'## Author
Alex Choi, [email protected]
## License
Giphy-iOS is available under the MIT license. See the LICENSE file for more info.