Reputation: 1463
Are there any methods in objective C for converting byte to int, float and NSString?
Upvotes: 0
Views: 2315
Reputation: 5666
You could get an NSString from NSData with initWithData:encoding:
and then transform it into int or float by calling intValue
and floatValue
Upvotes: 0
Reputation: 9364
The first are C-types. No conversion is needed, just assign them:
byte b = ...;
int x = b;
float f = b;
Converting to NSString could be done using stringWithFormat:
, a NSNumberFormatter
and many more methods. This is the easiest:
NSString *myString = [NSString stringWithFormat: @"%d", b];
If you want it printed in hex, use @"%x"
(for lowercase letters) or @"%X"
(for capital letters) instead.
Upvotes: 3