-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSymbol+Archiving.m
executable file
·57 lines (49 loc) · 1.78 KB
/
Symbol+Archiving.m
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
50
51
52
53
54
55
56
57
//
// Symbol+Archiving.m
// Trinity
//
// Created by Peter Appel on 05/01/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "Symbol.h"
@implementation Symbol (Archiving)
- (id)initWithCoder:(NSCoder *)coder
{
if (![coder allowsKeyedCoding])
{
NSLog(@"Symbol only works with NSKeyedArchiver");
}
NSData *idData = [coder decodeObjectForKey:@"identificator"];
NSString *newID = [NSKeyedUnarchiver unarchiveObjectWithData:idData];
[self setIdentificator:newID];
[self setXLoc:[coder decodeFloatForKey:@"xLoc"]];
[self setYLoc:[coder decodeFloatForKey:@"yLoc"]];
[self setaValue:[coder decodeFloatForKey:@"aValue"]];
[self setbValue:[coder decodeFloatForKey:@"bValue"]];
[self setcValue:[coder decodeFloatForKey:@"cValue"]];
[self setRadius:[coder decodeFloatForKey:@"radius"]];
[self setPathType:[coder decodeIntForKey:@"pathType"]];
NSData *colorData = [coder decodeObjectForKey:@"color"];
NSColor *newColor = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
[self setColor:newColor];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
if (![coder allowsKeyedCoding])
{
NSLog(@"Symbol only works with NSKeyedArchiver");
}
NSData *idData = [NSKeyedArchiver archivedDataWithRootObject:identificator];
[coder encodeObject:idData forKey:@"identificator"];
[coder encodeFloat:[self xLoc] forKey:@"xLoc"];
[coder encodeFloat:[self yLoc] forKey:@"yLoc"];
[coder encodeFloat:[self aValue] forKey:@"aValue"];
[coder encodeFloat:[self bValue] forKey:@"bValue"];
[coder encodeFloat:[self cValue] forKey:@"cValue"];
[coder encodeInt:[self pathType] forKey:@"pathType"];
[coder encodeFloat:[self radius] forKey:@"radius"];
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:color];
[coder encodeObject:colorData forKey:@"color"];
}
@end