Skip to content

Commit

Permalink
Friend class confirms to NSCoding protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
mootoh committed Jun 21, 2009
1 parent c6164b2 commit 6c83160
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Classes/Friend.h
Expand Up @@ -11,20 +11,23 @@
@class CLLocation;
@class UIImage;

@interface Friend : NSObject
@interface Friend : NSObject <NSCoding>
{
NSString *name;
NSString *image_url;
UIImage *image;
CLLocation *location;
NSDate *last_update;
}

@property (nonatomic, assign) NSString *name;
@property (nonatomic, assign) NSString *image_url;
@property (nonatomic, assign) UIImage *image;
@property (nonatomic, assign) CLLocation *location;
@property (nonatomic, assign) NSDate *last_update;

- (id) initWithName:(NSString *)nm;
- (void) update; // retrieve latest information from the server
- (void) cacheImage; // retrieve image from image_url and cache it

@end
16 changes: 15 additions & 1 deletion Classes/Friend.m
Expand Up @@ -10,7 +10,7 @@

@implementation Friend

@synthesize name, image, location, last_update;
@synthesize name, image_url, image, location, last_update;

- (id) initWithName:(NSString *)nm
{
Expand All @@ -20,6 +20,16 @@ - (id) initWithName:(NSString *)nm
return self;
}

- (id) initWithCoder:(NSCoder *) decoder
{
self.name = [decoder decodeObjectForKey:@"name"];
self.image_url = [decoder decodeObjectForKey:@"image_url"];
self.location = [decoder decodeObjectForKey:@"location"];
self.last_update = [decoder decodeObjectForKey:@"last_update"];

return self;
}

- (void) dealloc
{
[name release];
Expand All @@ -33,4 +43,8 @@ - (void) update
{
}

- (void) cacheImage
{
}

@end

0 comments on commit 6c83160

Please sign in to comment.