Skip to content

Commit

Permalink
Formatting, Cleanup Public APIs
Browse files Browse the repository at this point in the history
Move several pieces of the API to private, rename parts ot the Public
API to be more consistent with other Objective C libraries.
  • Loading branch information
Alex Billingsley committed Feb 17, 2013
1 parent b59a67b commit cdfa729
Show file tree
Hide file tree
Showing 54 changed files with 613 additions and 954 deletions.
4 changes: 2 additions & 2 deletions Podfile
Expand Up @@ -5,10 +5,10 @@ workspace 'SignalR.Client.ObjC'

target :"SignalR.Client.iOS", :exclusive => true do
platform :ios, '5.0'
pod 'AFNetworking', '1.0.1'
pod 'AFNetworking', '>=1.0.0'
end

target :"SignalR.Client.OSX", :exclusive => true do
platform :osx, '10.7'
pod 'AFNetworking', '1.0.1'
pod 'AFNetworking', '>=1.0.0'
end
12 changes: 6 additions & 6 deletions Podfile.lock
@@ -1,12 +1,12 @@

COCOAPODS: 0.16.2

DEPENDENCIES:
- AFNetworking (= 1.0.1)
- AFNetworking (= 1.0.1)
- AFNetworking (>= 1.0.0)
- AFNetworking (>= 1.0.0)

PODS:
- AFNetworking (1.0.1)

COCOAPODS: 0.14.0
- AFNetworking (1.1.0)

SPEC CHECKSUMS:
AFNetworking: 4c11f857c9a18d65f4257c90a1e74ac49f0ac422
AFNetworking: 761a418233d280c1e0580bcb76ff9cb4c3073d17
Binary file added SignalR.Client.ObjC/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SignalR.Client.ObjC/Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SignalR.Client.ObjC/Default@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 52 additions & 12 deletions SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Expand Up @@ -177,7 +177,7 @@ -(void)refreshRoom:(id)inRoom
[self clearMessages];
[self clearUsers];

[hub invoke:@"GetUsers" withArgs:@[] continueWith:^(id users) {
[hub invoke:@"GetUsers" withArgs:@[] completionHandler:^(id users) {
for(id user in users)
{
if([user isKindOfClass:[NSDictionary class]]){
Expand Down
Expand Up @@ -72,7 +72,7 @@ - (void)viewDidLoad
_connection.started = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Opened" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.received = ^(NSString * data){
//__strong __typeof(&*weakSelf)strongSelf = weakSelf;
Expand All @@ -82,12 +82,12 @@ - (void)viewDidLoad
_connection.closed = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Closed" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.error = ^(NSError *error){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:error.localizedDescription atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
[_connection start];
}
Expand Down
Expand Up @@ -76,7 +76,7 @@ - (void)viewDidLoad
_connection.started = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Opened" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.received = ^(NSString * data){
//__strong __typeof(&*weakSelf)strongSelf = weakSelf;
Expand All @@ -86,12 +86,12 @@ - (void)viewDidLoad
_connection.closed = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Closed" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.error = ^(NSError *error){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:error.localizedDescription atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
[_connection start];
}
Expand Down
Expand Up @@ -67,22 +67,22 @@ - (void)viewDidLoad
_connection.started = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Opened" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.received = ^(NSString * data){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:data atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.closed = ^{
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:@"Connection Closed" atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
_connection.error = ^(NSError *error){
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.data insertObject:error.localizedDescription atIndex:0];
[self.tableView reloadData];
[strongSelf.tableView reloadData];
};
[_connection start];
}
Expand Down
12 changes: 6 additions & 6 deletions SignalR.Client/Http/SRDefaultHttpClient.m
Expand Up @@ -27,7 +27,7 @@

@implementation SRDefaultHttpClient

- (void)getAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest continueWith:(SRResponseBlock)block {
- (void)getAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest completionHandler:(SRResponseBlock)block {
if (url == nil) {
[NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url should be non-null",@"")];
}
Expand All @@ -38,13 +38,13 @@ - (void)getAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest
req = [[SRDefaultHttpWebRequestWrapper alloc] initWithRequest:request];
if (prepareRequest)
prepareRequest(req);
} continueWith:^(id response) {
} completionHandler:^(id response) {
if (block)
block([[SRDefaultHttpWebResponseWrapper alloc] initWithRequest:req withResponse:response]);
}];
}

- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest continueWith:(SRResponseBlock)block {
- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest completionHandler:(SRResponseBlock)block {
if (url == nil) {
[NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url should be non-null",@"")];
}
Expand All @@ -55,13 +55,13 @@ - (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest
req = [[SRDefaultHttpWebRequestWrapper alloc] initWithRequest:request];
if (prepareRequest)
prepareRequest(req);
} continueWith:^(id response) {
} completionHandler:^(id response) {
if (block)
block([[SRDefaultHttpWebResponseWrapper alloc] initWithRequest:req withResponse:response]);
}];
}

- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest postData:(id)postData continueWith:(SRResponseBlock)block {
- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest postData:(id)postData completionHandler:(SRResponseBlock)block {
if (url == nil) {
[NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url should be non-null",@"")];
}
Expand All @@ -74,7 +74,7 @@ - (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest
prepareRequest(req);
}
postData:postData
continueWith:^(id response) { if (block) block([[SRDefaultHttpWebResponseWrapper alloc] initWithRequest:req withResponse:response]); }];
completionHandler:^(id response) { if (block) block([[SRDefaultHttpWebResponseWrapper alloc] initWithRequest:req withResponse:response]); }];
}

@end
42 changes: 21 additions & 21 deletions SignalR.Client/Http/SRDefaultHttpHelper.m
Expand Up @@ -73,7 +73,7 @@ @interface SRDefaultHttpHelper ()
* This can be used to modify properties of the POST, for example timeout or cache protocol
* @param block: A function to be called when the post finishes. The block should handle both SUCCESS and FAILURE
*/
+ (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters continueWith:(SRContinueWithBlock)block;
+ (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters completionHandler:(SRCompletionHandler)block;

#pragma mark -
#pragma mark POST Requests Implementation
Expand All @@ -88,7 +88,7 @@ + (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)reque
* This can be used to modify properties of the POST, for example timeout or cache protocol
* @param block: A function to be called when the post finishes. The block should handle both SUCCESS and FAILURE
*/
+ (void)postInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData continueWith:(SRContinueWithBlock)block;
+ (void)postInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData completionHandler:(SRCompletionHandler)block;

@end

Expand All @@ -97,23 +97,23 @@ @implementation SRDefaultHttpHelper
#pragma mark -
#pragma mark GET Requests Implementation

+ (void)getAsync:(NSString *)url continueWith:(SRContinueWithBlock)block {
[[self class] getAsync:url requestPreparer:nil continueWith:block];
+ (void)getAsync:(NSString *)url completionHandler:(SRCompletionHandler)block {
[[self class] getAsync:url requestPreparer:nil completionHandler:block];
}

+ (void)getAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer continueWith:(SRContinueWithBlock)block {
[[self class] getAsync:url requestPreparer:requestPreparer parameters:[[NSDictionary alloc] init] continueWith:block];
+ (void)getAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer completionHandler:(SRCompletionHandler)block {
[[self class] getAsync:url requestPreparer:requestPreparer parameters:[[NSDictionary alloc] init] completionHandler:block];
}

+ (void)getAsync:(NSString *)url parameters:(id)parameters continueWith:(SRContinueWithBlock)block {
[[self class] getAsync:url requestPreparer:nil parameters:parameters continueWith:block];
+ (void)getAsync:(NSString *)url parameters:(id)parameters completionHandler:(SRCompletionHandler)block {
[[self class] getAsync:url requestPreparer:nil parameters:parameters completionHandler:block];
}

+ (void)getAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters continueWith:(SRContinueWithBlock)block {
[[self class] getInternal:url requestPreparer:requestPreparer parameters:parameters continueWith:block];
+ (void)getAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters completionHandler:(SRCompletionHandler)block {
[[self class] getInternal:url requestPreparer:requestPreparer parameters:parameters completionHandler:block];
}

+ (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters continueWith:(SRContinueWithBlock)block {
+ (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer parameters:(id)parameters completionHandler:(SRCompletionHandler)block {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"GET"];
[request setValue:@"Keep-Alive" forHTTPHeaderField:@"Connection"];
Expand Down Expand Up @@ -155,23 +155,23 @@ + (void)getInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)reque
#pragma mark -
#pragma mark POST Requests Implementation

+ (void)postAsync:(NSString *)url continueWith:(SRContinueWithBlock)block {
[[self class] postAsync:url requestPreparer:nil continueWith:block];
+ (void)postAsync:(NSString *)url completionHandler:(SRCompletionHandler)block {
[[self class] postAsync:url requestPreparer:nil completionHandler:block];
}

+ (void)postAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer continueWith:(SRContinueWithBlock)block {
[[self class] postAsync:url requestPreparer:requestPreparer postData:[[NSDictionary alloc] init] continueWith:block];
+ (void)postAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer completionHandler:(SRCompletionHandler)block {
[[self class] postAsync:url requestPreparer:requestPreparer postData:[[NSDictionary alloc] init] completionHandler:block];
}

+ (void)postAsync:(NSString *)url postData:(id)postData continueWith:(SRContinueWithBlock)block {
[[self class] postAsync:url requestPreparer:nil postData:postData continueWith:block];
+ (void)postAsync:(NSString *)url postData:(id)postData completionHandler:(SRCompletionHandler)block {
[[self class] postAsync:url requestPreparer:nil postData:postData completionHandler:block];
}

+ (void)postAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData continueWith:(SRContinueWithBlock)block {
[[self class] postInternal:url requestPreparer:requestPreparer postData:postData continueWith:block];
+ (void)postAsync:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData completionHandler:(SRCompletionHandler)block {
[[self class] postInternal:url requestPreparer:requestPreparer postData:postData completionHandler:block];
}

+ (void)postInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData continueWith:(SRContinueWithBlock)block {
+ (void)postInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requestPreparer postData:(id)postData completionHandler:(SRCompletionHandler)block {
NSMutableArray *components = [NSMutableArray array];
for (NSString *key in [postData allKeys]) {
[components addObject:[NSString stringWithFormat:@"%@=%@",key,postData[key]]];
Expand All @@ -182,7 +182,7 @@ + (void)postInternal:(NSString *)url requestPreparer:(SRPrepareRequestBlock)requ
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setValue:[NSString stringWithFormat:@"%ld", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
[request setTimeoutInterval:240];
if(requestPreparer != nil) {
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Client/Http/SRDefaultHttpWebRequestWrapper.h
Expand Up @@ -25,6 +25,6 @@

@interface SRDefaultHttpWebRequestWrapper : NSObject <SRRequest>

- (id)initWithRequest:(id)request;
- (instancetype)initWithRequest:(id)request;

@end
2 changes: 1 addition & 1 deletion SignalR.Client/Http/SRDefaultHttpWebRequestWrapper.m
Expand Up @@ -39,7 +39,7 @@ @implementation SRDefaultHttpWebRequestWrapper
@synthesize headers = _headers;
@synthesize accept = _accept;

- (id)initWithRequest:(id)request {
- (instancetype)initWithRequest:(id)request {
if (self = [super init]) {
if([request isKindOfClass:[NSMutableURLRequest class]]) {
_request = request;
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Client/Http/SRDefaultHttpWebResponseWrapper.h
Expand Up @@ -26,6 +26,6 @@

@interface SRDefaultHttpWebResponseWrapper : NSObject <SRResponse>

- (id)initWithRequest:(id <SRRequest>)request withResponse:(id)response;
- (instancetype)initWithRequest:(id <SRRequest>)request withResponse:(id)response;

@end
2 changes: 1 addition & 1 deletion SignalR.Client/Http/SRDefaultHttpWebResponseWrapper.m
Expand Up @@ -33,7 +33,7 @@ @implementation SRDefaultHttpWebResponseWrapper
@synthesize stream = _stream;
@synthesize error = _error;

- (id)initWithRequest:(id <SRRequest>)request withResponse:(id)response {
- (instancetype)initWithRequest:(id <SRRequest>)request withResponse:(id)response {
static NSString *empty = @"";

if (self = [super init]) {
Expand Down
6 changes: 3 additions & 3 deletions SignalR.Client/Http/SRHttpClient.h
Expand Up @@ -29,9 +29,9 @@ typedef void (^SRResponseBlock)(id <SRResponse> response);

@protocol SRHttpClient <NSObject>

- (void)getAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest continueWith:(SRResponseBlock)block;
- (void)getAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest completionHandler:(SRResponseBlock)block;

- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest continueWith:(SRResponseBlock)block;
- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest postData:(id)postData continueWith:(SRResponseBlock)block;
- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest completionHandler:(SRResponseBlock)block;
- (void)postAsync:(NSString *)url requestPreparer:(SRRequestBlock)prepareRequest postData:(id)postData completionHandler:(SRResponseBlock)block;

@end

0 comments on commit cdfa729

Please sign in to comment.