This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
forked from gimenete/iOS-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// TwitterSearchClient.h | ||
// IOSBoilerplate | ||
// | ||
// Created by Mattt Thompson on 11/10/31. | ||
// Copyright (c) 2011年 Gowalla. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "AFHTTPClient.h" | ||
|
||
@interface TwitterSearchClient : AFHTTPClient | ||
+ (TwitterSearchClient *)sharedClient; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// TwitterSearchClient.m | ||
// IOSBoilerplate | ||
// | ||
// Created by Mattt Thompson on 11/10/31. | ||
// Copyright (c) 2011年 Gowalla. All rights reserved. | ||
// | ||
|
||
#import "TwitterSearchClient.h" | ||
|
||
#import "AFJSONRequestOperation.h" | ||
|
||
NSString * const kTwitterBaseURLString = @"https://search.twitter.com/"; | ||
|
||
|
||
@implementation TwitterSearchClient | ||
|
||
+ (TwitterSearchClient *)sharedClient { | ||
static TwitterSearchClient *_sharedClient = nil; | ||
static dispatch_once_t oncePredicate; | ||
dispatch_once(&oncePredicate, ^{ | ||
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kTwitterBaseURLString]]; | ||
}); | ||
|
||
return _sharedClient; | ||
} | ||
|
||
- (id)initWithBaseURL:(NSURL *)url { | ||
self = [super initWithBaseURL:url]; | ||
if (!self) { | ||
return nil; | ||
} | ||
|
||
[self registerHTTPOperationClass:[AFJSONRequestOperation class]]; | ||
|
||
// Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 | ||
[self setDefaultHeader:@"Accept" value:@"application/json"]; | ||
|
||
// X-UDID HTTP Header | ||
[self setDefaultHeader:@"X-UDID" value:[[UIDevice currentDevice] uniqueIdentifier]]; | ||
|
||
return self; | ||
} | ||
|
||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters