Skip to content
This repository
Browse code

Adding NSCoding conformance to AFOAuth1Client

  • Loading branch information...
commit 5030fbaa3658e2c3ae96266e7d6e0a75a3f57823 1 parent 3e02873
Mattt Thompson mattt authored
2  AFOAuth1Client/AFOAuth1Client.h
@@ -31,7 +31,7 @@ typedef enum {
31 31 /**
32 32
33 33 */
34   -@interface AFOAuth1Client : AFHTTPClient
  34 +@interface AFOAuth1Client : AFHTTPClient <NSCoding>
35 35
36 36 ///-----------------------------------
37 37 /// @name Managing OAuth Configuration
30 AFOAuth1Client/AFOAuth1Client.m
@@ -153,6 +153,7 @@ @implementation AFOAuth1Client
153 153 @synthesize secret = _secret;
154 154 @synthesize signatureMethod = _signatureMethod;
155 155 @synthesize realm = _realm;
  156 +@synthesize accessToken = _accessToken;
156 157 @synthesize oauthAccessMethod = _oauthAccessMethod;
157 158
158 159 - (id)initWithBaseURL:(NSURL *)url
@@ -368,6 +369,35 @@ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
368 369 return request;
369 370 }
370 371
  372 +#pragma mark - NSCoding
  373 +
  374 +- (id)initWithCoder:(NSCoder *)decoder {
  375 + self = [super initWithCoder:decoder];
  376 + if (!self) {
  377 + return nil;
  378 + }
  379 +
  380 + self.key = [decoder decodeObjectForKey:@"key"];
  381 + self.secret = [decoder decodeObjectForKey:@"secret"];
  382 + self.signatureMethod = (AFOAuthSignatureMethod)[decoder decodeIntegerForKey:@"signatureMethod"];
  383 + self.realm = [decoder decodeObjectForKey:@"realm"];
  384 + self.accessToken = [decoder decodeObjectForKey:@"accessToken"];
  385 + self.oauthAccessMethod = [decoder decodeObjectForKey:@"oauthAccessMethod"];
  386 +
  387 + return self;
  388 +}
  389 +
  390 +- (void)encodeWithCoder:(NSCoder *)coder {
  391 + [super encodeWithCoder:coder];
  392 +
  393 + [coder encodeObject:self.key forKey:@"key"];
  394 + [coder encodeObject:self.secret forKey:@"secret"];
  395 + [coder encodeInteger:self.signatureMethod forKey:@"signatureMethod"];
  396 + [coder encodeObject:self.realm forKey:@"realm"];
  397 + [coder encodeObject:self.accessToken forKey:@"accessToken"];
  398 + [coder encodeObject:self.oauthAccessMethod forKey:@"oauthAccessMethod"];
  399 +}
  400 +
371 401 @end
372 402
373 403 #pragma mark -

0 comments on commit 5030fba

Please sign in to comment.
Something went wrong with that request. Please try again.