-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathNSAttributeDescription.j
85 lines (74 loc) · 2.69 KB
/
NSAttributeDescription.j
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// NSAttributeDescription.j
//
// Created by Raphael Bartolome on 06.01.10.
//
var xcprototypes = [
0, //NSUndefinedAttributeType
100, //NSInteger16AttributeType
200, //NSInteger32AttributeType
300, //NSInteger64AttributeType
400, //NSDecimalAttributeType
500, //NSDoubleAttributeType
600, //NSFloatAttributeType
700, //NSStringAttributeType
800, //NSBooleanAttributeType
900, //NSDateAttributeType
1000, //NSBinaryDataAttributeType
1800 //NSTransformableAttributeType
];
var xcprototypes_cp = [
CPDUndefinedAttributeType, //NSUndefinedAttributeType
CPDIntegerAttributeType, //NSInteger16AttributeType
CPDIntegerAttributeType, //NSInteger32AttributeType
CPDIntegerAttributeType, //NSInteger64AttributeType
CPDDecimalAttributeType, //NSDecimalAttributeType
CPDDoubleAttributeType, //NSDoubleAttributeType
CPDFloatAttributeType, //NSFloatAttributeType
CPDStringAttributeType, //NSStringAttributeType
CPDBooleanAttributeType, //NSBooleanAttributeType
CPDDateAttributeType, //NSDateAttributeType
CPDBinaryDataAttributeType, //NSBinaryDataAttributeType
CPDTransformableAttributeType //NSTransformableAttributeType
];
@implementation NSAttributeDescription : CPAttributeDescription
{
CPString ns_valueTransformerName @accessors(property=valueTransformerName);
NSEntityDescription ns_entity @accessors(property=entity);
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
[self setTypeValue:[self NS_attributeType:[aCoder decodeIntForKey: @"NSAttributeType"]]];
[self setOptional:[aCoder decodeBoolForKey: @"NSIsOptional"]];
[self setClassValue:[[aCoder decodeObjectForKey: @"NSAttributeValueClassName"] stringByReplacingOccurrencesOfString:@"NS" withString:@"CP"]];
[self setDefaultValue:[aCoder decodeObjectForKey: @"NSDefaultValue"]];
[self setName:[aCoder decodeObjectForKey: @"NSPropertyName"]];
[self setUserInfo:[aCoder decodeObjectForKey: @"NSUserInfo"]];
[self setValueTransformerName:[aCoder decodeObjectForKey: @"NSValueTransformerName"]];
ns_entity = [aCoder decodeObjectForKey: @"NSEntity"]; //is set in NSEntityDescription
}
return self;
}
- (int)NS_attributeType:(int) aTypeValue
{
var result = 0;
var i = 0;
while(i < xcprototypes.length)
{
if(aTypeValue == xcprototypes[i])
{
result = xcprototypes_cp[i];
break;
}
i++;
}
return result;
}
- (Class)classForKeyedArchiver
{
return [NSAttributeDescription class];
}
@end