Fwd: Accessing a managedObject property from within an accessor of another property
Fwd: Accessing a managedObject property from within an accessor of another property
- Subject: Fwd: Accessing a managedObject property from within an accessor of another property
- From: Brad Stone <email@hidden>
- Date: Tue, 22 Feb 2011 09:13:49 -0600
FYI - my managedObject is defined as such:
@interface Note : NSManagedObject
{
}
@property (nonatomic, retain) NSNumber * uid;
@property (nonatomic, retain) NSString * category;
@property (nonatomic, retain) NSNumber * isEncrypted;
@interface Note (CoreDataGeneratedPrimitiveAccessors)
- (NSString *)primitiveCategory;
- (void)setPrimitiveCategory:(NSString *)value;
@end
@implementation Note
@dynamic uid;
@dynamic category;
@dynamic isEncrypted;
- (NSString *)category
{
NSString * tmpValue;
[self willAccessValueForKey:@"category"];
tmpValue = [self primitiveCategory];
[self didAccessValueForKey:@"category"];
if ([[self valueForKey:@"isEncrypted"] boolValue]) {
//code to decrypt tmpValue
}
return tmpValue;
}
- (void)setCategory:(NSString *)value
{
if ([[self valueForKey:@"isEncrypted"] boolValue]) {
// code to encrypt tmpValue
}
[self willChangeValueForKey:@"category"];
[self setPrimitiveCategory:value];
[self didChangeValueForKey:@"category"];
}
- (BOOL)validateCategory:(id *)valueRef error:(NSError **)outError
{
// Insert custom validation logic here.
return YES;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden