Home > OS >  improper setting variable in objectiveC
improper setting variable in objectiveC

Time:09-17

I'm facing issue that xcode showing me warning: Incompatible pointer to integer conversion sending 'id _Nullable' to parameter of type 'unsigned long long'

the line is:

NSDecimalNumber *amount_total = [NSDecimalNumber decimalNumberWithMantissa:indic[@"amount"] exponent:-2 isNegative:NO];

it complain of indic[@"amount"] and this is a value of amount came from React-Native. even if I console log this in xcode it showing me a number which is came right from RN.

any solution to avoid that, however the app also crash because of this.

Thanks

CodePudding user response:

Foundation collections (including NSDictionary) store numbers as NSNumber objects. The error is informing you that it is expecting an unsigned long long, so you should use unsignedLongLongValue to extract that value from the NSNumber in your NSDictionary:

NSDecimalNumber *amount_total = [NSDecimalNumber decimalNumberWithMantissa:[indic[@"amount"] unsignedLongLongValue] exponent:-2 isNegative:NO];

See Most Collections Are Objects and Numbers Are Represented by Instances of the NSNumber Class.

  • Related