Skip to content

Commit 0481d55

Browse files
committed
Changing iOS example to Twitter Client
1 parent f11c93d commit 0481d55

25 files changed

+535
-4230
lines changed

iOS Example/AFNetworking iOS Example.xcodeproj/project.pbxproj

Lines changed: 114 additions & 133 deletions
Large diffs are not rendered by default.

iOS Example/AppDelegate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// AFNetworkingExampleAppDelegate.h
1+
// AppDelegate.h
22
//
3-
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
3+
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
44
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
2626

2727
}
2828

29-
@property (nonatomic, retain) UIWindow *window;
30-
@property (nonatomic, retain) UINavigationController *navigationController;
29+
@property (nonatomic, strong) UIWindow *window;
30+
@property (nonatomic, strong) UINavigationController *navigationController;
3131

3232
@end

iOS Example/AppDelegate.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// AFNetworkingExampleAppDelegate.m
1+
// AppDelegate.m
22
//
3-
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
3+
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
44
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +21,7 @@
2121
// THE SOFTWARE.
2222

2323
#import "AppDelegate.h"
24-
#import "NearbySpotsViewController.h"
24+
#import "PublicTimelineViewController.h"
2525

2626
#import "AFNetworkActivityIndicatorManager.h"
2727

@@ -30,26 +30,22 @@ @implementation AppDelegate
3030
@synthesize navigationController = _navigationController;
3131

3232
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
33-
NSURLCache *URLCache = [[[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil] autorelease];
33+
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 diskCapacity:1024 * 1024 * 5 diskPath:nil];
3434
[NSURLCache setSharedURLCache:URLCache];
3535

3636
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
3737

38-
UITableViewController *viewController = [[[NearbySpotsViewController alloc] init] autorelease];
39-
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];
38+
UITableViewController *viewController = [[PublicTimelineViewController alloc] initWithStyle:UITableViewStylePlain];
39+
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
40+
self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
4041

41-
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
42+
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
4243
self.window.backgroundColor = [UIColor whiteColor];
4344
self.window.rootViewController = self.navigationController;
4445
[self.window makeKeyAndVisible];
4546

4647
return YES;
4748
}
4849

49-
- (void)dealloc {
50-
[_window release];
51-
[_navigationController release];
52-
[super dealloc];
53-
}
5450

5551
@end

iOS Example/Classes/AFGowallaAPIClient.h renamed to iOS Example/Classes/AFTwitterAPIClient.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// AFGowallaAPI.h
1+
// AFTwitterAPIClient.h
22
//
3-
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
3+
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
44
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
@@ -23,9 +23,8 @@
2323
#import <Foundation/Foundation.h>
2424
#import "AFHTTPClient.h"
2525

26-
extern NSString * const kAFGowallaClientID;
27-
extern NSString * const kAFGowallaBaseURLString;
26+
@interface AFTwitterAPIClient : AFHTTPClient
27+
28+
+ (AFTwitterAPIClient *)sharedClient;
2829

29-
@interface AFGowallaAPIClient : AFHTTPClient
30-
+ (AFGowallaAPIClient *)sharedClient;
3130
@end

iOS Example/Classes/AFGowallaAPIClient.m renamed to iOS Example/Classes/AFTwitterAPIClient.m

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// AFGowallaAPI.m
1+
// AFTwitterAPIClient.h
22
//
3-
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
3+
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
44
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
@@ -20,22 +20,19 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
#import "AFGowallaAPIClient.h"
23+
#import "AFTwitterAPIClient.h"
2424

2525
#import "AFJSONRequestOperation.h"
2626

27-
// Replace this with your own API Key, available at http://api.gowalla.com/api/keys/
28-
NSString * const kAFGowallaClientID = @"e7ccb7d3d2414eb2af4663fc91eb2793";
27+
static NSString * const kAFTwitterAPIBaseURLString = @"http://api.twitter.com/1/";
2928

30-
NSString * const kAFGowallaBaseURLString = @"https://api.gowalla.com/";
29+
@implementation AFTwitterAPIClient
3130

32-
@implementation AFGowallaAPIClient
33-
34-
+ (AFGowallaAPIClient *)sharedClient {
35-
static AFGowallaAPIClient *_sharedClient = nil;
36-
static dispatch_once_t oncePredicate;
37-
dispatch_once(&oncePredicate, ^{
38-
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAFGowallaBaseURLString]];
31+
+ (AFTwitterAPIClient *)sharedClient {
32+
static AFTwitterAPIClient *_sharedClient = nil;
33+
static dispatch_once_t onceToken;
34+
dispatch_once(&onceToken, ^{
35+
_sharedClient = [[AFTwitterAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kAFTwitterAPIBaseURLString]];
3936
});
4037

4138
return _sharedClient;
@@ -52,15 +49,6 @@ - (id)initWithBaseURL:(NSURL *)url {
5249
// Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
5350
[self setDefaultHeader:@"Accept" value:@"application/json"];
5451

55-
// X-Gowalla-API-Key HTTP Header; see http://api.gowalla.com/api/docs
56-
[self setDefaultHeader:@"X-Gowalla-API-Key" value:kAFGowallaClientID];
57-
58-
// X-Gowalla-API-Version HTTP Header; see http://api.gowalla.com/api/docs
59-
[self setDefaultHeader:@"X-Gowalla-API-Version" value:@"1"];
60-
61-
// X-UDID HTTP Header
62-
[self setDefaultHeader:@"X-UDID" value:[[UIDevice currentDevice] uniqueIdentifier]];
63-
6452
return self;
6553
}
6654

iOS Example/Classes/Controllers/NearbySpotsViewController.m

Lines changed: 0 additions & 189 deletions
This file was deleted.

iOS Example/Classes/Views/SpotTableViewCell.h renamed to iOS Example/Classes/Controllers/PublicTimelineViewController.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// SpotTableViewCell.h
1+
// PublicTimelineViewController.h
22
//
3-
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
3+
// Copyright (c) 2012 Mattt Thompson (http://mattt.me/)
44
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
@@ -22,10 +22,6 @@
2222

2323
#import <UIKit/UIKit.h>
2424

25-
@class Spot;
26-
27-
@interface SpotTableViewCell : UITableViewCell
28-
29-
@property (nonatomic, retain) Spot *spot;
25+
@interface PublicTimelineViewController : UITableViewController
3026

3127
@end

0 commit comments

Comments
 (0)