Please tell me how to convert bytes to NSInteger/int in objective-c in iPhone programming?
Please tell me how to convert bytes to NSInteger/int in objective-c in iPhone programming?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What do you mean by “Bytes”?
If you want convert single byte representing integer value to int (or NSInteger) type, just use “=”:
as Byte (the same as unsigned char – 1 byte unsigned integer) and NSInteger (the same as int – 4 bytes signed integer) are both of simple integer types and can be converted automatically. Your should read more about “c data types” and “conversion rules“.
for example http://www.exforsys.com/tutorials/c-language/c-programming-language-data-types.html
If you want to convert several bytes storing some value to int, then convertion depends on structure of these data: how many bytes per value, signed or unsigned.