25 #import "CoreDataHeaders.h"
27 @implementation NSPropertyDescription
32 TEST_RELEASE(_userInfo);
33 TEST_RELEASE(_validationPredicates);
34 TEST_RELEASE(_validationWarnings);
44 - (void) setName: (NSString *) aName
46 [
self _ensureEditableWithReason: @"Tried to set name of a property "
51 - (NSEntityDescription *) entity
61 - (void) setOptional: (BOOL) flag
63 [
self _ensureEditableWithReason: @"Tried to optionality of a property "
73 - (void) setTransient: (BOOL) flag
75 [
self _ensureEditableWithReason: @"Tried to set transient-ness of a"
76 @" property already in use."];
80 - (NSDictionary *) userInfo
85 - (void) setUserInfo: (NSDictionary *) userInfo
87 [
self _ensureEditableWithReason: @"Tried to set user info of a property "
89 ASSIGN(_userInfo, userInfo);
92 - (NSArray *) validationPredicates
94 return _validationPredicates;
97 - (NSArray *) validationWarnings
99 return _validationWarnings;
102 - (void) setValidationPredicates: (NSArray *) someValidationPredicates
103 withValidationWarnings: (NSArray *) someValidationWarnings
105 [
self _ensureEditableWithReason: @"Tried to set validation predicates and "
106 @"validation warnings of a property "
108 ASSIGN(_validationPredicates, someValidationPredicates);
109 ASSIGN(_validationWarnings, someValidationWarnings);
114 - (id) copyWithZone: (NSZone *) zone
116 NSPropertyDescription * property;
118 property = [NSPropertyDescription new];
119 [property setName: _name];
120 [property setOptional: _optional];
121 [property setTransient: _transient];
122 [property setUserInfo: _userInfo];
123 [property setValidationPredicates: _validationPredicates
124 withValidationWarnings: _validationWarnings];
131 - (id) initWithCoder: (NSCoder *) coder
133 if ((
self = [super init]))
135 if ([coder allowsKeyedCoding])
137 ASSIGN(_name, [coder decodeObjectForKey:
@"Name"]);
138 ASSIGN(_userInfo, [coder decodeObjectForKey:
@"UserInfo"]);
139 ASSIGN(_validationPredicates, [coder decodeObjectForKey:
140 @"ValidationPredicates"]);
141 ASSIGN(_validationWarnings, [coder decodeObjectForKey:
142 @"ValidationPredicates"]);
144 _entity = [coder decodeObjectForKey: @"Entity"];
146 _optional = [coder decodeBoolForKey: @"Optional"];
147 _transient = [coder decodeBoolForKey: @"Transient"];
151 ASSIGN(_name, [coder decodeObject]);
152 ASSIGN(_userInfo, [coder decodeObject]);
153 ASSIGN(_validationPredicates, [coder decodeObject]);
154 ASSIGN(_validationWarnings, [coder decodeObject]);
156 _entity = [coder decodeObject];
158 [coder decodeValueOfObjCType: @encode(typeof(_optional))
160 [coder decodeValueOfObjCType: @encode(typeof(_transient))
167 - (void) encodeWithCoder: (NSCoder *) coder
169 if ([coder allowsKeyedCoding])
171 [coder encodeObject: _name forKey: @"Name"];
172 [coder encodeObject: _userInfo forKey: @"UserInfo"];
173 [coder encodeObject: _validationPredicates
174 forKey: @"ValidationPredicates"];
175 [coder encodeObject: _validationWarnings
176 forKey: @"ValidationWarnings"];
178 [coder encodeObject: _entity forKey: @"Entity"];
180 [coder encodeBool: _optional forKey: @"Optional"];
181 [coder encodeBool: _transient forKey: @"Transient"];
185 [coder encodeObject: _name];
186 [coder encodeObject: _userInfo];
187 [coder encodeObject: _validationPredicates];
188 [coder encodeObject: _validationWarnings];
190 [coder encodeObject: _entity];
192 [coder encodeValueOfObjCType: @encode(typeof(_optional))
194 [coder encodeValueOfObjCType: @encode(typeof(_transient))
201 @implementation NSPropertyDescription (GSCoreDataPrivate)
207 - (void) _setEntity: (NSEntityDescription *) entity
220 - (void) _ensureEditableWithReason: (NSString *) reason
222 NSManagedObjectModel * model;
224 model = [_entity managedObjectModel];
225 if (model != nil && [model _isEditable] == NO)
227 [NSException raise: NSGenericException format: _(reason)];