From ef482fe022bd6152cc21ce81f5d1456b2e0fcd07 Mon Sep 17 00:00:00 2001 From: Sean Cook Date: Fri, 1 Aug 2014 23:33:34 -0700 Subject: [PATCH] Removes log statements --- Source/Classes/TWTAPIManager.m | 19 ++----------------- Source/Classes/TWTViewController.m | 13 ++++--------- Source/Other/ReverseAuthExample-Prefix.pch | 16 ---------------- 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Source/Classes/TWTAPIManager.m b/Source/Classes/TWTAPIManager.m index d4343e5..8db4fc4 100644 --- a/Source/Classes/TWTAPIManager.m +++ b/Source/Classes/TWTAPIManager.m @@ -75,9 +75,6 @@ + (BOOL)isLocalTwitterAccountAvailable */ - (SLRequest *)requestWithUrl:(NSURL *)url parameters:(NSDictionary *)dict requestMethod:(SLRequestMethod)requestMethod { - NSParameterAssert(url); - NSParameterAssert(dict); - return [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:requestMethod URL:url parameters:dict]; } @@ -92,11 +89,8 @@ - (SLRequest *)requestWithUrl:(NSURL *)url parameters:(NSDictionary *)dict reque */ - (void)performReverseAuthForAccount:(ACAccount *)account withHandler:(TWTAPIHandler)handler { - NSParameterAssert(account); [self _step1WithCompletion:^(NSData *data, NSError *error) { if (!data) { - TWDLog(@"Step 1 FAILED with error %@\n", [error localizedDescription]); - dispatch_async(dispatch_get_main_queue(), ^{ handler(nil, error); }); @@ -126,15 +120,9 @@ - (void)performReverseAuthForAccount:(ACAccount *)account withHandler:(TWTAPIHan */ - (void)_step2WithAccount:(ACAccount *)account signature:(NSString *)signedReverseAuthSignature andHandler:(TWTAPIHandler)completion { - NSParameterAssert(account); - NSParameterAssert(signedReverseAuthSignature); - NSDictionary *step2Params = @{TWT_X_AUTH_REVERSE_TARGET: [TWTSignedRequest consumerKey], TWT_X_AUTH_REVERSE_PARMS: signedReverseAuthSignature}; NSURL *authTokenURL = [NSURL URLWithString:TWT_OAUTH_URL_AUTH_TOKEN]; SLRequest *step2Request = [self requestWithUrl:authTokenURL parameters:step2Params requestMethod:SLRequestMethodPOST]; - - TWDLog(@"Step 2: Sending a request to %@\nparameters %@\n", authTokenURL, step2Params); - [step2Request setAccount:account]; [step2Request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @@ -154,11 +142,8 @@ - (void)_step2WithAccount:(ACAccount *)account signature:(NSString *)signedRever - (void)_step1WithCompletion:(TWTAPIHandler)completion { NSURL *url = [NSURL URLWithString:TWT_OAUTH_URL_REQUEST_TOKEN]; - NSDictionary *dict = @{TWT_X_AUTH_MODE_KEY: TWT_X_AUTH_MODE_REVERSE_AUTH}; - TWTSignedRequest *step1Request = [[TWTSignedRequest alloc] initWithURL:url parameters:dict requestMethod:TWSignedRequestMethodPOST]; - - TWDLog(@"Step 1: Sending a request to %@\nparameters %@\n", url, dict); - + NSDictionary *params = @{TWT_X_AUTH_MODE_KEY: TWT_X_AUTH_MODE_REVERSE_AUTH}; + TWTSignedRequest *step1Request = [[TWTSignedRequest alloc] initWithURL:url parameters:params requestMethod:TWSignedRequestMethodPOST]; [step1Request performRequestWithHandler:^(NSData *data, NSURLResponse *response, NSError *error) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ completion(data, error); diff --git a/Source/Classes/TWTViewController.m b/Source/Classes/TWTViewController.m index f1f9976..e537615 100644 --- a/Source/Classes/TWTViewController.m +++ b/Source/Classes/TWTViewController.m @@ -87,8 +87,8 @@ - (void)loadView _reverseAuthBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [_reverseAuthBtn setTitle:@"Perform Token Exchange" forState:UIControlStateNormal]; [_reverseAuthBtn addTarget:self action:@selector(performReverseAuth:) forControlEvents:UIControlEventTouchUpInside]; - _reverseAuthBtn.frame = buttonFrame; - _reverseAuthBtn.enabled = NO; + [_reverseAuthBtn setFrame:buttonFrame]; + [_reverseAuthBtn setEnabled:NO]; [_reverseAuthBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [view addSubview:_reverseAuthBtn]; @@ -120,9 +120,6 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger [_apiManager performReverseAuthForAccount:_accounts[buttonIndex] withHandler:^(NSData *responseData, NSError *error) { if (responseData) { NSString *responseStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; - - TWDLog(@"Reverse Auth process returned: %@", responseStr); - NSArray *parts = [responseStr componentsSeparatedByString:@"&"]; NSString *lined = [parts componentsJoinedByString:@"\n"]; @@ -132,13 +129,14 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger }); } else { - TWALog(@"Reverse Auth process failed. Error returned was: %@\n", [error localizedDescription]); + NSLog(@"Reverse Auth process failed. Error returned was: %@\n", [error localizedDescription]); } }]; } } #pragma mark - Private + - (void)_displayAlertWithMessage:(NSString *)message { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ERROR_TITLE_MSG message:message delegate:nil cancelButtonTitle:ERROR_OK otherButtonTitles:nil]; @@ -158,8 +156,6 @@ - (void)_displayAlertWithMessage:(NSString *)message */ - (void)_refreshTwitterAccounts { - TWDLog(@"Refreshing Twitter Accounts \n"); - if (![TWTAPIManager hasAppKeys]) { [self _displayAlertWithMessage:ERROR_NO_KEYS]; } @@ -174,7 +170,6 @@ - (void)_refreshTwitterAccounts } else { [self _displayAlertWithMessage:ERROR_PERM_ACCESS]; - TWALog(@"You were not granted access to the Twitter accounts."); } }); }]; diff --git a/Source/Other/ReverseAuthExample-Prefix.pch b/Source/Other/ReverseAuthExample-Prefix.pch index cbdae62..5643f5f 100644 --- a/Source/Other/ReverseAuthExample-Prefix.pch +++ b/Source/Other/ReverseAuthExample-Prefix.pch @@ -12,19 +12,3 @@ #ifdef AWESOME_ALL_AROUND_PERSON #warning "Interested in a job at Twitter? Send me a note: theSeanCook@twitter.com" #endif - -// -// I use a variation of these logging methods in most projects. -// Based on http://stackoverflow.com/a/969291/48062 -// -#ifdef DEBUG -# define TWDLog(fmt, ...) NSLog((@"\n%s\n" fmt), __PRETTY_FUNCTION__, ##__VA_ARGS__) -#else -# define TWDLog(...) -#endif - - -// -// Logs regardless of debug setting. -// -#define TWALog(fmt, ...) NSLog((@"\n%s\n" fmt), __PRETTY_FUNCTION__, ##__VA_ARGS__)