Re: Array controllers in code?
Re: Array controllers in code?
- Subject: Re: Array controllers in code?
- From: Amy Gibbs <email@hidden>
- Date: Thu, 22 Jul 2010 21:03:05 +0100
I've tried declaring all sorts of things trying to get it to work :D
float, decimal, (the entity properties are decimal in the datamodel),
NSNumber, but I still get the error: invalid operands to binary /
I assume I can't use int as the figures aren't integers, I only need
it to 2 decimal places (for currency).
This is what I've now got, and the only error I'm getting is the
error:invalid operands to binary. I've been outputting to NSLog and
it's showing the right numbers, until it gets to the actual division
(I have to remove the division to get it to run, and then it shows the
right numbers for price and uom)
Thanks for all your help, I'm not used to having to declare everything
in this way, usually dabble in PHP :(
On 22 Jul 2010, at 7:51PM, Ken Thomases wrote:
On Jul 22, 2010, at 1:20 PM, Amy Gibbs wrote:
double *price, *uom, *cost;
You have declared pointers to double, a scalar type. "double" is
_not_ an object type.
price = [Product valueForKey:@"UOMcost"];
uom = [Product valueForKey:@"purchaseUOM"];
The above is wrong, and the compiler probably complained about it. -
valueForKey: is not returning a double nor a pointer to a double.
Most likely, in your case, it is returning a pointer to an NSNumber
object. You can ask an NSNumber for a double value (which, again,
will not be a pointer to a double).
cost = uom/price;
although the actual calculation won't work, not sure why, example
values are price=8.8, uom=25, getting an error:invalid operands to
binary?
That's because you are attempting to divide two pointers. That
doesn't make sense.
Regards,
Ken
_______________________________________________
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