I'm increasing the amount of a model field using the following code:
- (IBAction) counterButton: (id) sender {
[model.amount++ stringValue];
}
It was working fine until I upgraded Xcode. Since then I've been getting the following error:
"Arithmetic on pointer to Interface 'NSNumber'. which is not a constant size in non-fragile ABI"
When the code was working it incremented the value by 1 each time a UIButton was touched.
any help would be greatly appreciated. thanks
You cant perform ++ on a NSNumber
which in an object not a primitive type.
Also it is an unmutable type.
If you want increase the value of amount you can try this:
- (IBAction) counterButton: (id) sender {
NSInteger amount =[model.amount integerValue];
amount++;
model.amount = [NSNumber numberWithInteger:amount];
}
Unless model.amount
used to be an NSInteger
I don't see how that would ever have worked. The ++
operator doesn't work on NSNumber
s. Or at least, it doesn't increment the value that's stored in it -- instead it would increment the pointer to the object, which isn't what you want.
Instead you need to increment the value "long hand."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With