diff --git a/OAMutableURLRequest.m b/OAMutableURLRequest.m index b738dcd..dd68638 100644 --- a/OAMutableURLRequest.m +++ b/OAMutableURLRequest.m @@ -85,14 +85,10 @@ - (id)initWithURL:(NSURL *)aUrl signatureProvider:(id)aProvider nonce:(NSString *)aNonce timestamp:(NSString *)aTimestamp { - [self initWithURL:aUrl - consumer:aConsumer - token:aToken - realm:aRealm - signatureProvider:aProvider]; - - nonce = [aNonce copy]; - timestamp = [aTimestamp copy]; + if ((self = [self initWithURL:aUrl consumer:aConsumer token:aToken realm:aRealm signatureProvider:aProvider])) { + nonce = [aNonce copy]; + timestamp = [aTimestamp copy]; + } return self; } diff --git a/OAToken.m b/OAToken.m index df1f21a..b9b7edd 100644 --- a/OAToken.m +++ b/OAToken.m @@ -117,19 +117,20 @@ - (id)initWithHTTPResponseBody:(const NSString *)body { } - (id)initWithUserDefaultsUsingServiceProviderName:(const NSString *)provider prefix:(const NSString *)prefix { - [super init]; - self.key = [OAToken loadSetting:@"key" provider:provider prefix:prefix]; - self.secret = [OAToken loadSetting:@"secret" provider:provider prefix:prefix]; - self.session = [OAToken loadSetting:@"session" provider:provider prefix:prefix]; - self.duration = [OAToken loadSetting:@"duration" provider:provider prefix:prefix]; - self.attributes = [OAToken loadSetting:@"attributes" provider:provider prefix:prefix]; - created = [OAToken loadSetting:@"created" provider:provider prefix:prefix]; - renewable = [[OAToken loadSetting:@"renewable" provider:provider prefix:prefix] boolValue]; - - if (![self isValid]) { - [self autorelease]; - return nil; - } + if ((self = [super init])) { + self.key = [OAToken loadSetting:@"key" provider:provider prefix:prefix]; + self.secret = [OAToken loadSetting:@"secret" provider:provider prefix:prefix]; + self.session = [OAToken loadSetting:@"session" provider:provider prefix:prefix]; + self.duration = [OAToken loadSetting:@"duration" provider:provider prefix:prefix]; + self.attributes = [OAToken loadSetting:@"attributes" provider:provider prefix:prefix]; + created = [OAToken loadSetting:@"created" provider:provider prefix:prefix]; + renewable = [[OAToken loadSetting:@"renewable" provider:provider prefix:prefix] boolValue]; + + if (![self isValid]) { + [self autorelease]; + return nil; + } + } return self; }