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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Paul B.
  • 458
  • 3
  • 6
  • Get rid of the asterisk. NSUInteger is not a class. – rmaddy May 02 '14 at 03:02
  • Oh, jeez! That did it. Thank you so much, Maddy! I feel pretty silly now. This is my first question so I'm not sure how to mark something as the answer. It doesn't appear as though I can do that with your comment. Are you able to answer in a different way that I can mark so you get the points? – Paul B. May 02 '14 at 03:12

1 Answers1

1

This line:

NSUInteger *roundingMethod;

should be:

NSUInteger roundingMethod;

NSUInteger is a native type, not a class type.

rmaddy
  • 314,917
  • 42
  • 532
  • 579