On 21 Jun 2011, at 6:48 AM, Amy Heavey wrote:

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

My first steps would be to break in the debugger and type these in the console:

po product
po [product valueForKey: @"kitFee"]

If product is an array, then sending valueForKey: to it would yield another 
array, with the kitFee of each member. Then you can audit your code to see why 
you're getting an array instead of what you wanted (did you forget that 
executeFetchRequest:error: returns an array?). Though if the same code, but 
with kitName, works, it would indicate that product isn't an array.

        — F

_______________________________________________

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