Skip to content

Commit

Permalink
Add NSCoding support to auth token so it can be persisted easily
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeredpath committed May 17, 2010
1 parent 25b0c04 commit 415cd67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/LROAuth2AccessToken.h
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>


@interface LROAuth2AccessToken : UIView {
@interface LROAuth2AccessToken : UIView <NSCoding> {
NSDictionary *authResponseData;
NSDate *expiresAt;
}
Expand Down
18 changes: 18 additions & 0 deletions Classes/LROAuth2AccessToken.m
Expand Up @@ -56,4 +56,22 @@ - (NSString *)refreshToken;
return [authResponseData valueForKey:@"refresh_token"];
}

#pragma mark -
#pragma mark NSCoding

- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:authResponseData forKey:@"data"];
[aCoder encodeObject:expiresAt forKey:@"expiresAt"];
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init]) {
authResponseData = [[aDecoder decodeObjectForKey:@"data"] copy];
expiresAt = [[aDecoder decodeObjectForKey:@"expiresAt"] retain];
}
return self;
}

@end

0 comments on commit 415cd67

Please sign in to comment.