做藍牙功能的時候用到了很多類型轉換,記錄一下。
1、字符串轉data
2、data轉字符串
3、十六進制字符串轉中文
時候時調用這個方法[self changeLanguage:string]; ?用字符串接收就行
4、字符串金額 ? 轉為分 ?再轉16進制 ? 再補位(藍牙涉及到了充值)
5、十六進制字符串轉十進制
[NSString stringWithFormat:@"%ld",strtoul([想轉的字符串 UTF8String],0,16)];
做藍牙功能的時候用到了很多類型轉換,記錄一下。
1、字符串轉data
2、data轉字符串
3、十六進制字符串轉中文
時候時調用這個方法[self changeLanguage:string]; ?用字符串接收就行
4、字符串金額 ? 轉為分 ?再轉16進制 ? 再補位(藍牙涉及到了充值)
5、十六進制字符串轉十進制
[NSString stringWithFormat:@"%ld",strtoul([想轉的字符串 UTF8String],0,16)];