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 (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to