Skip to content

Commit

Permalink
Convert to ARC.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed Apr 1, 2012
1 parent e0cef1c commit ea80e95
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Classes/LROAuth2AccessToken.h
Expand Up @@ -13,8 +13,8 @@
NSDictionary *authResponseData;
NSDate *expiresAt;
}
@property (nonatomic, readonly) NSString *accessToken;
@property (nonatomic, readonly) NSString *refreshToken;
@property (unsafe_unretained, nonatomic, readonly) NSString *accessToken;
@property (unsafe_unretained, nonatomic, readonly) NSString *refreshToken;
@property (nonatomic, readonly) NSDate *expiresAt;

- (id)initWithAuthorizationResponse:(NSDictionary *)_data;
Expand Down
9 changes: 1 addition & 8 deletions Classes/LROAuth2AccessToken.m
Expand Up @@ -31,12 +31,6 @@ - (id)initWithAuthorizationResponse:(NSDictionary *)data;
return self;
}

- (void)dealloc;
{
[expiresAt release];
[authResponseData release];
[super dealloc];
}

- (NSString *)description;
{
Expand All @@ -56,7 +50,6 @@ - (void)refreshFromAuthorizationResponse:(NSDictionary *)data;
[tokenData setObject:[data objectForKey:@"expires_in"] forKey:@"expires_in"];

[self setAuthResponseData:tokenData];
[tokenData release];
[self extractExpiresAtFromResponse];
}

Expand Down Expand Up @@ -92,7 +85,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init]) {
authResponseData = [[aDecoder decodeObjectForKey:@"data"] copy];
expiresAt = [[aDecoder decodeObjectForKey:@"expiresAt"] retain];
expiresAt = [aDecoder decodeObjectForKey:@"expiresAt"];
}
return self;
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/LROAuth2Client.h
Expand Up @@ -20,7 +20,7 @@
NSURL *tokenURL;
LROAuth2AccessToken *accessToken;
NSMutableArray *requests;
id<LROAuth2ClientDelegate> delegate;
id<LROAuth2ClientDelegate> __unsafe_unretained delegate;
BOOL debug;

@private
Expand All @@ -33,7 +33,7 @@
@property (nonatomic, copy) NSURL *userURL;
@property (nonatomic, copy) NSURL *tokenURL;
@property (nonatomic, readonly) LROAuth2AccessToken *accessToken;
@property (nonatomic, assign) id<LROAuth2ClientDelegate> delegate;
@property (nonatomic, unsafe_unretained) id<LROAuth2ClientDelegate> delegate;
@property (nonatomic, assign) BOOL debug;

- (id)initWithClientID:(NSString *)_clientID
Expand Down
25 changes: 10 additions & 15 deletions Classes/LROAuth2Client.m
Expand Up @@ -6,7 +6,6 @@
// Copyright 2010 LJR Software Limited. All rights reserved.
//

#import <YAJLIOS/NSObject+YAJL.h>
#import "LROAuth2Client.h"
#import "NSURL+QueryInspector.h"
#import "LROAuth2AccessToken.h"
Expand Down Expand Up @@ -47,14 +46,6 @@ - (id)initWithClientID:(NSString *)_clientID
- (void)dealloc;
{
[_networkQueue cancelAllOperations];
[accessToken release];
[clientID release];
[clientSecret release];
[userURL release];
[tokenURL release];
[redirectURL release];
[cancelURL release];
[super dealloc];
}

#pragma mark -
Expand All @@ -76,7 +67,7 @@ - (NSURLRequest *)userAuthorizationRequestWithParameters:(NSDictionary *)additio
NSMutableURLRequest *authRequest = [NSMutableURLRequest requestWithURL:fullURL];
[authRequest setHTTPMethod:@"GET"];

return [[authRequest copy] autorelease];
return [authRequest copy];
}

- (void)verifyAuthorizationWithAccessCode:(NSString *)accessCode;
Expand All @@ -98,10 +89,12 @@ - (void)verifyAuthorizationWithAccessCode:(NSString *)accessCode;
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[[params stringWithFormEncodedComponents] dataUsingEncoding:NSUTF8StringEncoding]];

__block LRURLRequestOperation *operation = [[LRURLRequestOperation alloc] initWithURLRequest:request];
LRURLRequestOperation *operation = [[LRURLRequestOperation alloc] initWithURLRequest:request];

__unsafe_unretained id blockOperation = operation;

[operation setCompletionBlock:^{
[self handleCompletionForAuthorizationRequestOperation:operation];
[self handleCompletionForAuthorizationRequestOperation:blockOperation];
}];

[_networkQueue addOperation:operation];
Expand All @@ -110,7 +103,7 @@ - (void)verifyAuthorizationWithAccessCode:(NSString *)accessCode;

- (void)refreshAccessToken:(LROAuth2AccessToken *)_accessToken;
{
accessToken = [_accessToken retain];
accessToken = _accessToken;

NSDictionary *params = [NSMutableDictionary dictionary];
[params setValue:@"refresh" forKey:@"type"];
Expand All @@ -124,10 +117,12 @@ - (void)refreshAccessToken:(LROAuth2AccessToken *)_accessToken;
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[[params stringWithFormEncodedComponents] dataUsingEncoding:NSUTF8StringEncoding]];

__block LRURLRequestOperation *operation = [[LRURLRequestOperation alloc] initWithURLRequest:request];
LRURLRequestOperation *operation = [[LRURLRequestOperation alloc] initWithURLRequest:request];

__unsafe_unretained id blockOperation = operation;

[operation setCompletionBlock:^{
[self handleCompletionForAuthorizationRequestOperation:operation];
[self handleCompletionForAuthorizationRequestOperation:blockOperation];
}];

[_networkQueue addOperation:operation];
Expand Down
10 changes: 4 additions & 6 deletions LROAuth2Client.xcodeproj/project.pbxproj
Expand Up @@ -14,15 +14,13 @@
A3289DB1122D708700D89A88 /* NSURL+QueryInspector.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8C130119DF00D0035081C /* NSURL+QueryInspector.m */; };
A3289DB2122D708700D89A88 /* LROAuth2Client.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8BFBB119DEE450035081C /* LROAuth2Client.m */; };
A3289DB3122D708700D89A88 /* LROAuth2AccessToken.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8BFBE119DEE450035081C /* LROAuth2AccessToken.m */; };
A3289EA2122D755D00D89A88 /* YAJLIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3289EA1122D755D00D89A88 /* YAJLIOS.framework */; };
A3289EB6122D758F00D89A88 /* NSDictionary+QueryString.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8C24B119DF7420035081C /* NSDictionary+QueryString.m */; };
A3289EB7122D758F00D89A88 /* NSString+QueryString.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8C24C119DF7420035081C /* NSString+QueryString.m */; };
A3289EB8122D758F00D89A88 /* NSURL+QueryInspector.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8C130119DF00D0035081C /* NSURL+QueryInspector.m */; };
A3289EB9122D758F00D89A88 /* LROAuth2Client.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8BFBB119DEE450035081C /* LROAuth2Client.m */; };
A3289EBA122D758F00D89A88 /* LROAuth2AccessToken.m in Sources */ = {isa = PBXBuildFile; fileRef = A3F8BFBE119DEE450035081C /* LROAuth2AccessToken.m */; };
A3289EBC122D758F00D89A88 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3F8C124119DEFD50035081C /* SystemConfiguration.framework */; };
A3289EBD122D758F00D89A88 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3F8C126119DEFDE0035081C /* UIKit.framework */; };
A3289EBF122D758F00D89A88 /* YAJLIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3289EA1122D755D00D89A88 /* YAJLIOS.framework */; };
A3289FD6122D819500D89A88 /* LROAuth2Client.h in Headers */ = {isa = PBXBuildFile; fileRef = A3F8BFBA119DEE450035081C /* LROAuth2Client.h */; settings = {ATTRIBUTES = (Public, ); }; };
A3289FD7122D819500D89A88 /* LROAuth2ClientDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A3F8BFBC119DEE450035081C /* LROAuth2ClientDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
A3289FD8122D819500D89A88 /* LROAuth2AccessToken.h in Headers */ = {isa = PBXBuildFile; fileRef = A3F8BFBD119DEE450035081C /* LROAuth2AccessToken.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -37,7 +35,6 @@

/* Begin PBXFileReference section */
A3289D4B122D705500D89A88 /* libLROAuth2Client-Device.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libLROAuth2Client-Device.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A3289EA1122D755D00D89A88 /* YAJLIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = YAJLIOS.framework; path = Vendor/YAJLIOS.framework; sourceTree = "<group>"; };
A3289EC3122D758F00D89A88 /* libLROAuth2Client-Simulator.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libLROAuth2Client-Simulator.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A3ABE4D41528797B006E9AC0 /* LRURLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRURLRequestOperation.h; sourceTree = "<group>"; };
A3ABE4D51528797B006E9AC0 /* LRURLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRURLRequestOperation.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -68,7 +65,6 @@
files = (
A3289DAD122D707B00D89A88 /* SystemConfiguration.framework in Frameworks */,
A3289DAE122D707B00D89A88 /* UIKit.framework in Frameworks */,
A3289EA2122D755D00D89A88 /* YAJLIOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -78,7 +74,6 @@
files = (
A3289EBC122D758F00D89A88 /* SystemConfiguration.framework in Frameworks */,
A3289EBD122D758F00D89A88 /* UIKit.framework in Frameworks */,
A3289EBF122D758F00D89A88 /* YAJLIOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -111,7 +106,6 @@
children = (
B25E609B11CFB581001DA5CD /* MobileCoreServices.framework */,
B25E609711CFB581001DA5CD /* CFNetwork.framework */,
A3289EA1122D755D00D89A88 /* YAJLIOS.framework */,
AACBBE490F95108600F1A2B1 /* Foundation.framework */,
A3F8C124119DEFD50035081C /* SystemConfiguration.framework */,
A3F8C126119DEFDE0035081C /* UIKit.framework */,
Expand Down Expand Up @@ -364,6 +358,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -374,6 +369,7 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREFIX_HEADER = LROAuth2Client_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
OTHER_LDFLAGS = (
"-ObjC",
"-all_load",
Expand All @@ -388,6 +384,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -398,6 +395,7 @@
);
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_PREFIX_HEADER = LROAuth2Client_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
OTHER_LDFLAGS = (
"-ObjC",
"-all_load",
Expand Down
4 changes: 2 additions & 2 deletions NSString+QueryString.m
Expand Up @@ -14,15 +14,15 @@ - (NSString*)stringByEscapingForURLQuery
{
NSString *result = self;

CFStringRef originalAsCFString = (CFStringRef) self;
CFStringRef originalAsCFString = (__bridge CFStringRef) self;
CFStringRef leaveAlone = CFSTR(" ");
CFStringRef toEscape = CFSTR("\n\r?[]()$,!'*;:@&=#%+/");

CFStringRef escapedStr;
escapedStr = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, originalAsCFString, leaveAlone, toEscape, kCFStringEncodingUTF8);

if (escapedStr) {
NSMutableString *mutable = [NSMutableString stringWithString:(NSString *)escapedStr];
NSMutableString *mutable = [NSMutableString stringWithString:(__bridge NSString *)escapedStr];
CFRelease(escapedStr);

[mutable replaceOccurrencesOfString:@" " withString:@"+" options:0 range:NSMakeRange(0, [mutable length])];
Expand Down

0 comments on commit ea80e95

Please sign in to comment.