• 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: valueForUndefinedKey confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: valueForUndefinedKey confusion


  • Subject: Re: valueForUndefinedKey confusion
  • From: Graham Cox <email@hidden>
  • Date: Tue, 16 Feb 2010 09:09:56 +1100

On 16/02/2010, at 8:56 AM, James Maxwell wrote:

> I have an NSMutableDictionary I'm trying to read from, but it's giving me valueForUndefinedKey errors. I can NSLog the key successfully, so I'm very confused as to what's going on.
>
> NSLog(@"Total number of components in work: %i", [AllComponents count]);
> for(NSString* cKey in AllComponents)
> {
> 	NSLog(@"key? %@", cKey);
> 	MnSComponent *comp = (MnSComponent*)[AllComponents valueForKey:cKey];
> 	[comp buildPitchMatrix];
> 	[comp calculateTension];
> }
>
> The NSLog prints the expected key, then the code gags on the next line. ???

Try -objectForKey: instead of -valueForKey: there might be some subtlety of use KVC versus direct access that's screwing things up here. The key might contain characters that can be misinterpreted by KVC - containing '@' or '.' characters for example.

Also, are you certain that buildPitchMatrix and calculateTension are not mutating the dictionary? If they do the iteration will fail.

--Graham


_______________________________________________

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

  • Follow-Ups:
    • Re: valueForUndefinedKey confusion
      • From: James Maxwell <email@hidden>
References: 
 >valueForUndefinedKey confusion (From: James Maxwell <email@hidden>)

  • Prev by Date: valueForUndefinedKey confusion
  • Next by Date: Re: valueForUndefinedKey confusion
  • Previous by thread: valueForUndefinedKey confusion
  • Next by thread: Re: valueForUndefinedKey confusion
  • Index(es):
    • Date
    • Thread