Monday, December 26, 2011

Convert NSString to and from NSNumber in XCode-


Convert String to Number in XCode-
Variable declare-
NSNumberFormatter * numValue = [[NSNumberFormatter alloc] init];
Set the number variable to contain Decimal value.
[numValue setNumberStyle:NSNumberFormatterDecimalStyle];
Get the string value from string-
NSNumber * myNumber = [numValue numberFromString:@"7"];
Release memory-
[myNumber release];
Convert Number to String in XCode-
NSString *myStr = [NSString stringWithFormat:@"%d",intValueHere];
                                         

That’s it  Enjoy J

No comments: