Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OAToken conform to NSCoding, so it can be persisted without using the…

… strange userdefaults related methods
  • Loading branch information...
commit 42c42838ad5a1ca97c5a8b876005a895370cc992 1 parent 62e459b
@adamjernst adamjernst authored
Showing with 23 additions and 1 deletion.
  1. +1 −1  OAToken.h
  2. +22 −0 OAToken.m
View
2  OAToken.h
@@ -25,7 +25,7 @@
#import <Foundation/Foundation.h>
-@interface OAToken : NSObject {
+@interface OAToken : NSObject <NSCoding> {
@protected
NSString *key;
NSString *secret;
View
22 OAToken.m
@@ -68,6 +68,18 @@ - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret session:(NSString
return self;
}
+- (id)initWithCoder:(NSCoder *)aDecoder {
+ OAToken *t = [self initWithKey:[aDecoder decodeObjectForKey:@"key"]
+ secret:[aDecoder decodeObjectForKey:@"secret"]
+ session:[aDecoder decodeObjectForKey:@"session"]
+ duration:[aDecoder decodeObjectForKey:@"duration"]
+ attributes:[aDecoder decodeObjectForKey:@"attributes"]
+ created:[aDecoder decodeObjectForKey:@"created"]
+ renewable:[aDecoder decodeBoolForKey:@"renewable"]];
+ [t setVerifier:[aDecoder decodeObjectForKey:@"verifier"]];
+ return t;
+}
+
- (id)initWithHTTPResponseBody:(const NSString *)body {
NSString *aKey = nil;
NSString *aSecret = nil;
@@ -151,6 +163,16 @@ - (int)storeInUserDefaultsWithServiceProviderName:(const NSString *)provider pre
return(0);
}
+- (void)encodeWithCoder:(NSCoder *)aCoder {
+ [aCoder encodeObject:[self key] forKey:@"key"];
+ [aCoder encodeObject:[self secret] forKey:@"secret"];
+ [aCoder encodeObject:[self session] forKey:@"session"];
+ [aCoder encodeObject:[self duration] forKey:@"duration"];
+ [aCoder encodeObject:[self attributes] forKey:@"attributes"];
+ [aCoder encodeBool:renewable forKey:@"renewable"];
+ [aCoder encodeObject:[self verifier] forKey:@"verifier"];
+}
+
#pragma mark duration
- (void)setDurationWithString:(NSString *)aDuration {
Please sign in to comment.
Something went wrong with that request. Please try again.