Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Giphy API client for iOS in Objective-C

License

NotificationsYou must be signed in to change notification settings

heyalexchoi/Giphy-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VersionLicensePlatform

Giphy-iOS is aGiphy API client for iOS in Objective-C.

Usage

To run the example project, clone the repo, and runpod install from the Example directory first.

You should read aboutGiphy's Access and API keys here.

Giphy-iOS / AXCGiphy

'AXCGiphy' provides convenient access toGiphy's API endpoints:

  • search
  • trending
  • translate
  • GIF by ID
  • GIFs by IDs

You can query the endpoints through the blocks based interface:

- (void)viewDidLoad{    [superviewDidLoad];// set your API key before making any requests. You may use kGiphyPublicAPIKey for development.    [AXCGiphysetGiphyAPIKey:kGiphyPublicAPIKey];    [AXCGiphysearchGiphyWithTerm:@"frogs"limit:10offset:0completion:^(NSArray *results,NSError *error) {        self.giphyResults = results;        [[NSOperationQueuemainQueue]addOperationWithBlock:^{            [self.collectionViewreloadData];        }];    }];}- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{    AXCCollectionViewCell * cell = [collectionViewdequeueReusableCellWithReuseIdentifier:kCollectionViewCellIdentifierforIndexPath:indexPath];    AXCGiphy * gif = self.giphyResults[indexPath.item];NSURLRequest * request = [NSURLRequestrequestWithURL:gif.originalImage.url];    [[[NSURLSessionsharedSession]dataTaskWithRequest:requestcompletionHandler:^(NSData *data,NSURLResponse *response,NSError *error) {        UIImage * image = [UIImageimageWithData:data];        [[NSOperationQueuemainQueue]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 andmattt's AnimatedGifSerialization 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 throughCocoaPods. To installit, simply add the following line to your Podfile:

pod "Giphy-iOS"pod 'AFNetworking/Serialization', '~> 2.3.1'

Author

Alex Choi,heyalexchoi@gmail.com

License

Giphy-iOS is available under the MIT license. See the LICENSE file for more info.

About

Giphy API client for iOS in Objective-C

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp