• 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: attribute is an array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: attribute is an array?


  • Subject: Re: attribute is an array?
  • From: Roland King <email@hidden>
  • Date: Tue, 21 Jun 2011 19:58:49 +0800

On 21-Jun-2011, at 7:48 PM, Amy Heavey wrote:

> Hi,
>
> I'm trying to acccess a decimal attribute of an entity, and I can't work out why it's not working. I'm using the code below;
>
> NSString *price = [[product valueForKey:@"kitFee"] stringValue];
>
> and I get this error:
>
> 2011-06-21 12:43:34.666 ishop[30901:10b] *** -[NSCFArray stringValue]: unrecognized selector sent to instance 0xe74f030
>
> kitFee is a decimal attribute, and I can successfully get string attributes with this code, NSString *productName = [product valueForKey:@"kitName"];
>
> Does the error message mean that it's getting an array for kitFee when it should be a value?
>
> I've cleaned and rebuilt, and it's sticking at this line, but I just can't see my error?
>
> I'd appreciate any help,
>
> Many Thanks
>
> Amy

	NSString *productName = [ product valueForKey:@"kitName" ];

just assigns blindly whatever valueForKey: returns to an productName, which is really just an id which the compiler expects to be an NSString (ie the compiler will warn you if you call non-NSString methods on it). However that line alone doesn't prove that it's a NSString, could still be a NSArray.

What are you doing with productName which proves it is in fact a string? Are you logging it, do you see '[]' in the log message which might be a hint it's an array of strings?

What's product? Is that an array? valueForKey: on an array returns an array of answers. _______________________________________________

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: 
 >attribute is an array? (From: Amy Heavey <email@hidden>)

  • Prev by Date: attribute is an array?
  • Next by Date: Re: attribute is an array?
  • Previous by thread: attribute is an array?
  • Next by thread: Re: attribute is an array?
  • Index(es):
    • Date
    • Thread