Note that there are some explanatory texts on larger screens.

plurals
  1. POIncompatible Objective-C types initializing 'struct NSNumber *', expected 'struct NSDecimalNumber *'
    text
    copied!<p>I have the below method in my project, and I get a compiler warning: <code>Incompatible Objective-C types initializing 'struct NSNumber *', expected 'struct NSDecimalNumber *</code> on the first line:</p> <pre><code>- (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]; } </code></pre> <p>Any help would be appreciated, thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload