You have to initialize a new NSString
object using the right format specifier.
Like :
int i = 9;
NSString *octalString = [NSString stringWithFormat:@"%o", i]; // %O works too.
This will create an autoreleased NSString
object containing octal string representation of i
. In case you start from a NSString
containing a decimal number representation, you should first retrieve the number using :
int i = [myDecimalNumberAsAString intValue];
Here is a link to the format specifiers reference.
Hope this helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…