On Feb 22, 2011, at 3:19 PM, Brad Stone wrote:
> I've been trying for days to determine why I get EXC_BAD_ACCESS when I try to
> access a managedObject property from within an accessor of another property?
Could you post the stack trace? Just for debugging purposed: What happens if
you define another method (not an CoreData-Property)
like:
- (NSString*) categoryPlain
{
NSString* categoryEncryptedOrNot = self.category;
if ([self.isEncrypted boolValue]) {
// decrypt
return decryptedCategory;
}
return categoryEncryptedOrNot;
}
and leave "category" as a @dynamic-property. Maybe CoreDate gets confused if
you retrieve the value, but change
it after your didAccessValueForKey:-message send
Cheers,
Felix
>
> this code in main.m
> [[self note] setValue:@"HELLO WORLD" forKey:@"category"];
> NSNumber *tmpVal = [NSNumber numberWithBool:![[[self note]
> valueForKey:@"isEncrypted"] boolValue]]; // if I type po [self note] I see
> the note description
> [[self note] setValue:tmpVal forKey:@"isEncrypted"]; // if I type po [self
> note] after this I get EXEC_BAD_ACCESS
>
> The if statement in the accessor is causing the problem:
> - (NSString *)category {
> NSString * tmpValue;
>
> [self willAccessValueForKey:@"category"];
> tmpValue = [self primitiveCategory];
> [self didAccessValueForKey:@"category"];
>
> if ([[self valueForKey:@"isEncrypted"] boolValue]) { // THIS IS CAUSING
> THE PROBLEM
> // code to decrypt tmpValue
> }
>
> return tmpValue;
> }
>
> When I replace: if ([[self valueForKey:@"isEncrypted"] boolValue]) with if (1
> == 2 ) or if (1 == 1 ) it works
>
> FYI: in my .h file @property (nonatomic, retain) NSNumber * isEncrypted; and
> @dynamic isEncrypted; in .m_______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/franz%40ergosign.de
>
> This email sent to [email protected]
--
Mit freundlichen Grüßen,
Felix Franz
Lead Software Engineer
ERGOSIGN GmbH
Europa-Allee 12
66113 Saarbrücken
Phone: +49 681 98 84 12 14
Fax: +49 681 98 84 12 10
www.ergosign.de
HRB 11850
Amtsgericht Saarbrücken
Geschäftsführung:
Dr. Marcus Plach
Prof. Dr. Dieter Wallach
Sitz der Gesellschaft:
Saarbrücken
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]