0

Forgive me if I use the wrong terminology as I'm still a little new at iOS development. I've built a calculator-type app and I want users to be able to control how numbers are rounded. Here's the code I'm using:

-(NSString*)calculateWidthFromHeightString:(NSString*)height usingDimensions:(Favorite*)dimensions{

int decimalPlaces = [self.userData.rounding intValue];

NSUInteger *roundingMethod;
if ([self.userData.roundingMode isEqualToString:@"up"]) {
  roundingMethod = NSRoundUp;
}
else if ([self.userData.roundingMode isEqualToString:@"plain"]) {
    roundingMethod = NSRoundPlain;
}
else {
    roundingMethod = NSRoundDown;
}

NSDecimalNumberHandler *handler = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:roundingMethod
scale:decimalPlaces
raiseOnExactness:NO
raiseOnOverflow:NO
raiseOnUnderflow:NO
raiseOnDivideByZero:NO];

This works as expected, but I'm getting the following compiler warning where I assign the rounding mode to the pointer "roundingMethod":

Incompatible Integer to pointer conversion assigning to ‘NSUInteger *’ (aka ‘unassigned long *) from ‘NSUInteger’ (aka ‘unassigned long’) Incompatible Integer to pointer conversion assigning to ‘NSUInteger *’ (aka ‘unassigned int *) from ‘NSUInteger’ (aka ‘unassigned int’)

I don't really know what this means. Any help would be greatly appreciated.

4

1 回答 1

1

这一行:

NSUInteger *roundingMethod;

应该:

NSUInteger roundingMethod;

NSUInteger是本机类型,而不是类类型。

于 2014-05-02T03:17:36.783 回答