Conversion for NSString to NSDecimalNumber in Objective-C
Asked Answered
P

2

5

What is the conversion for NSString to NSDecimalNumber?

unsigned long long order;

if (i==1) {
    order = [feeArray objectAtIndex:0];
}
if (i==2) {
    order = [amountArray objectAtIndex:0];
}
Phloem answered 10/7, 2012 at 7:37 Comment(0)
I
8

You can use NSDecimalNumber's decimalNumberWithString initializer to convert from a string

Ipswich answered 10/7, 2012 at 7:43 Comment(0)
M
4

Try this:

NSString *order = @"";
if (i==1) {
  order = [feeArray objectAtIndex:0];
}
if (i==2) {
  order = [amountArray objectAtIndex:0];
}

NSDecimalNumber *decimal = [NSDecimalNumber decimalNumberWithString:order];
Miru answered 10/7, 2012 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.