There's no built-in formatting operator to do that. If you wanted to convert it to a hexadecimal string, you could do:
NSString *str = [NSString stringWithFormat:@"%x", theNumber];
To convert it to a binary string, you'll have to build it yourself:
NSMutableString *str = [NSMutableString stringWithFormat:@""];
for(NSInteger numberCopy = theNumber; numberCopy > 0; numberCopy >>= 1)
{
// Prepend "0" or "1", depending on the bit
[str insertString:((numberCopy & 1) ? @"1" : @"0") atIndex:0];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…