Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding NSCoding conformance to AFOAuth1Client

  • Loading branch information...
commit 5030fbaa3658e2c3ae96266e7d6e0a75a3f57823 1 parent 3e02873
@mattt mattt authored
View
2  AFOAuth1Client/AFOAuth1Client.h
@@ -31,7 +31,7 @@ typedef enum {
/**
*/
-@interface AFOAuth1Client : AFHTTPClient
+@interface AFOAuth1Client : AFHTTPClient <NSCoding>
///-----------------------------------
/// @name Managing OAuth Configuration
View
30 AFOAuth1Client/AFOAuth1Client.m
@@ -153,6 +153,7 @@ @implementation AFOAuth1Client
@synthesize secret = _secret;
@synthesize signatureMethod = _signatureMethod;
@synthesize realm = _realm;
+@synthesize accessToken = _accessToken;
@synthesize oauthAccessMethod = _oauthAccessMethod;
- (id)initWithBaseURL:(NSURL *)url
@@ -368,6 +369,35 @@ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
return request;
}
+#pragma mark - NSCoding
+
+- (id)initWithCoder:(NSCoder *)decoder {
+ self = [super initWithCoder:decoder];
+ if (!self) {
+ return nil;
+ }
+
+ self.key = [decoder decodeObjectForKey:@"key"];
+ self.secret = [decoder decodeObjectForKey:@"secret"];
+ self.signatureMethod = (AFOAuthSignatureMethod)[decoder decodeIntegerForKey:@"signatureMethod"];
+ self.realm = [decoder decodeObjectForKey:@"realm"];
+ self.accessToken = [decoder decodeObjectForKey:@"accessToken"];
+ self.oauthAccessMethod = [decoder decodeObjectForKey:@"oauthAccessMethod"];
+
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+ [super encodeWithCoder:coder];
+
+ [coder encodeObject:self.key forKey:@"key"];
+ [coder encodeObject:self.secret forKey:@"secret"];
+ [coder encodeInteger:self.signatureMethod forKey:@"signatureMethod"];
+ [coder encodeObject:self.realm forKey:@"realm"];
+ [coder encodeObject:self.accessToken forKey:@"accessToken"];
+ [coder encodeObject:self.oauthAccessMethod forKey:@"oauthAccessMethod"];
+}
+
@end
#pragma mark -
Please sign in to comment.
Something went wrong with that request. Please try again.