Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Store 'color' in CBCanvas model
Browse files Browse the repository at this point in the history
  • Loading branch information
drpancake committed Apr 21, 2012
1 parent dd9d82f commit 403fdda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions layout/CBCanvas.h
Expand Up @@ -11,5 +11,6 @@
@interface CBCanvas : CBLayoutElement

@property (nonatomic, strong, readwrite) NSArray *points;
@property (nonatomic, strong, readwrite) NSString *color;

@end
8 changes: 6 additions & 2 deletions layout/CBCanvas.m
Expand Up @@ -11,12 +11,14 @@
@implementation CBCanvas

@synthesize points;
@synthesize color;

- (id)initWithJSON:(NSDictionary *)json
{
self = [super initWithJSON:json];
if (self) {
points = [json objectForKey:@"points"];
color = [json objectForKey:@"color"];
}
return self;
}
Expand All @@ -26,9 +28,11 @@ - (NSDictionary *)toJSON
NSDictionary *base = [super toJSON];
NSMutableDictionary *json = [[NSMutableDictionary alloc] initWithDictionary:base];

if (self.points) {
if (self.points)
[json setObject:self.points forKey:@"points"];
}

if (self.color)
[json setObject:self.color forKey:@"color"];

// Copy to immutable
return [NSDictionary dictionaryWithDictionary:json];
Expand Down

0 comments on commit 403fdda

Please sign in to comment.