• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing a managedObject property from within an accessor of another property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing a managedObject property from within an accessor of another property


  • Subject: Re: Accessing a managedObject property from within an accessor of another property
  • From: Felix Franz <email@hidden>
  • Date: Tue, 22 Feb 2011 20:55:20 +0100

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@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

--
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@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

References: 
 >Accessing a managedObject property from within an accessor of another property (From: Brad Stone <email@hidden>)

  • Prev by Date: Re: Reliable way to determine bitness of the kernel
  • Next by Date: Re: Accessing a managedObject property from within an accessor of another property
  • Previous by thread: Re: Accessing a managedObject property from within an accessor of another property
  • Next by thread: Problem opening file
  • Index(es):
    • Date
    • Thread