-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPBox+CPCoding.j
More file actions
49 lines (37 loc) · 1.63 KB
/
CPBox+CPCoding.j
File metadata and controls
49 lines (37 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
@import <AppKit/CPBox.j>
@import <Foundation/CPCoder.j>
var CPBoxBorderTypeKey = @"CPBoxBorderTypeKey",
CPBoxBorderColorKey = @"CPBoxBorderColorKey",
CPBoxFillColorKey = @"CPBoxFillColorKey",
CPBoxCornerRadiusKey = @"CPBoxCornerRadiusKey",
CPBoxBorderWidthKey = @"CPBoxBorderWidthKey",
CPBoxContentMarginKey = @"CPBoxContentMarginKey",
CPBoxContentViewKey = @"CPBoxContentViewKey";
@implementation CPBox (CPCoding)
- (id)initWithCoder:(CPCoder)coder
{
self = [super initWithCoder:coder];
if(self)
{
_borderType = [coder decodeObjectForKey:CPBoxBorderTypeKey];
_borderColor = [coder decodeObjectForKey:CPBoxBorderColorKey];
_fillColor = [coder decodeObjectForKey:CPBoxFillColorKey];
_cornerRadius = [coder decodeObjectForKey:CPBoxCornerRadiusKey];
_borderWidth = [coder decodeObjectForKey:CPBoxBorderWidthKey];
_contentMargin = [coder decodeObjectForKey:CPBoxContentMarginKey];
_contentView = [coder decodeObjectForKey:CPBoxContentViewKey];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)coder
{
[super encodeWithCoder:coder];
[coder encodeInt:_borderType forKey:CPBoxBorderTypeKey];
[coder encodeObject:_borderColor forKey:CPBoxBorderColorKey];
[coder encodeObject:_fillColor forKey:CPBoxFillColorKey];
[coder encodeFloat:_cornerRadius forKey:CPBoxCornerRadiusKey];
[coder encodeFloat:_borderWidth forKey:CPBoxBorderWidthKey];
[coder encodeSize:_contentMargin forKey:CPBoxContentMarginKey];
[coder encodeObject:_contentView forKey:CPBoxContentViewKey];
}
@end