Server has a Java Bean, it has a instance variable type BigDecimal
, but Objective-C cannot map it! I have tried NSNumber
, but doesn't work. Does anybody know how to fix it?
Asked
Active
Viewed 2,740 times
0

Smeegol
- 2,014
- 4
- 29
- 44
2 Answers
0
Just Try this once may be it is usefull
NSDecimalNumber *a = [NSDecimalNumber decimalNumberWithString:@"9999999999999999999999999999999999.99999999999"];
NSDecimalNumber *b;
NSDecimalNumber *half = [NSDecimalNumber decimalNumberWithString:@"999999999.9999999999"];
b = [half decimalNumberByAdding:a];
NSLog(@"The subtration :%@",b);

Pancho
- 4,099
- 1
- 21
- 32

srinivas n
- 640
- 4
- 20
0
Use NSDecimalNumber instead of NSNumber.
Here is the code to convert a string to a NSDecimal
-(NSDecimal) getDecimalFromString:(NSString*)representationString {
NSDecimal result;
NSScanner *theScanner = [[NSScanner alloc] initWithString:representationString];
[theScanner setLocale:[NSLocale currentLocale]];
[theScanner scanDecimal:&result];
return result;
}

Duyen-Hoa
- 15,384
- 5
- 35
- 44
-
I want to map remote Java bean with Objective-C protocols, the Java data type `long` is mapped with type `long` in Objective-C, but Xcode builds error and shows "Unknown type l for property long1 in protocol Test" :( What's the map list about data type translation? – Smeegol May 30 '14 at 09:45
-
is this what you need? http://rypress.com/tutorials/objective-c/data-types/primitives.html – Duyen-Hoa May 30 '14 at 09:51