Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
Removes log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Cook committed Aug 2, 2014
1 parent aef57b4 commit ef482fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
19 changes: 2 additions & 17 deletions Source/Classes/TWTAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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);
});
Expand Down Expand Up @@ -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), ^{
Expand All @@ -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);
Expand Down
13 changes: 4 additions & 9 deletions Source/Classes/TWTViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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"];

Expand All @@ -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];
Expand All @@ -158,8 +156,6 @@ - (void)_displayAlertWithMessage:(NSString *)message
*/
- (void)_refreshTwitterAccounts
{
TWDLog(@"Refreshing Twitter Accounts \n");

if (![TWTAPIManager hasAppKeys]) {
[self _displayAlertWithMessage:ERROR_NO_KEYS];
}
Expand All @@ -174,7 +170,6 @@ - (void)_refreshTwitterAccounts
}
else {
[self _displayAlertWithMessage:ERROR_PERM_ACCESS];
TWALog(@"You were not granted access to the Twitter accounts.");
}
});
}];
Expand Down
16 changes: 0 additions & 16 deletions Source/Other/ReverseAuthExample-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@
#ifdef AWESOME_ALL_AROUND_PERSON
#warning "Interested in a job at Twitter? Send me a note: [email protected]"
#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__)

0 comments on commit ef482fe

Please sign in to comment.