Permalink
Browse files

Adding NSCoding conformance to AFOAuth1Client

  • Loading branch information...
mattt committed May 7, 2013
1 parent 3e02873 commit 5030fbaa3658e2c3ae96266e7d6e0a75a3f57823
Showing with 31 additions and 1 deletion.
  1. +1 −1 AFOAuth1Client/AFOAuth1Client.h
  2. +30 −0 AFOAuth1Client/AFOAuth1Client.m
@@ -31,7 +31,7 @@ typedef enum {
/**
*/
-@interface AFOAuth1Client : AFHTTPClient
+@interface AFOAuth1Client : AFHTTPClient <NSCoding>
///-----------------------------------
/// @name Managing OAuth Configuration
@@ -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 -

0 comments on commit 5030fba

Please sign in to comment.