Hello,
I have the below method in my project, and I get a compiler warning: Incompatible Objective-C types initializing 'struct NSNumber *', expected 'struct NSDecimalNumber *
on the first line:
- (IBAction)sliderValueChanged:(id)sender {
// HERE IS WHERE THE WARNING OCCURS:
NSDecimalNumber *tempNumber = [NSDecimalNumber numberWithFloat:[self.slider value]];
NSDecimalNumberHandler *roundingStyle = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundBankers
scale:3
raiseOnExactness:NO
raiseOnOverflow:NO
raiseOnUnderflow:NO
raiseOnDivideByZero:NO];
NSDecimalNumber *roundedNumber = [tempNumber decimalNumberByRoundingAccordingToBehavior:roundingStyle];
self.slider.value = [roundedNumber floatValue];
// Set up the percentage formatter
NSNumberFormatter *percentFormatter = [[NSNumberFormatter alloc] init];
[percentFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[percentFormatter setMinimumFractionDigits:1];
[percentFormatter setMaximumFractionDigits:1];
// Find the label to update
NSUInteger onlyRow[] = {0, 0};
NSIndexPath *onlyRowPath = [NSIndexPath indexPathWithIndexes:onlyRow length:2];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:onlyRowPath];
UILabel *theLabel = (UILabel *)[cell.contentView viewWithTag:kLabelFieldTag];
NSNumber *theNumber = [NSNumber numberWithFloat:self.slider.value];
theLabel.text = [percentFormatter stringFromNumber:theNumber];
[percentFormatter release];
}
Any help would be appreciated, thanks!