当你有一些话不是很好意思说的时候,就用0和1代替吧,只有专属的才能翻译出来哦。
你可以直接发送01数据给别人,鬼知道你说什么。。。哈哈哈
主要代码就是
NSMutableDictionary *binaryDic = [[NSMutableDictionary alloc] initWithCapacity:16];
[binaryDic setObject:@"0" forKey:@"0000"];
[binaryDic setObject:@"1" forKey:@"0001"];
[binaryDic setObject:@"2" forKey:@"0010"];
[binaryDic setObject:@"3" forKey:@"0011"];
[binaryDic setObject:@"4" forKey:@"0100"];
[binaryDic setObject:@"5" forKey:@"0101"];
[binaryDic setObject:@"6" forKey:@"0110"];
[binaryDic setObject:@"7" forKey:@"0111"];
[binaryDic setObject:@"8" forKey:@"1000"];
[binaryDic setObject:@"9" forKey:@"1001"];
[binaryDic setObject:@"A" forKey:@"1010"];
[binaryDic setObject:@"B" forKey:@"1011"];
[binaryDic setObject:@"C" forKey:@"1100"];
[binaryDic setObject:@"D" forKey:@"1101"];
[binaryDic setObject:@"E" forKey:@"1110"];
[binaryDic setObject:@"F" forKey:@"1111"];
if (binary.length % 4 != 0) {
NSMutableString *mStr = [[NSMutableString alloc]init];;
for (int i = 0; i < 4 - binary.length % 4; i++) {
[mStr appendString:@"0"];
}
binary = [mStr stringByAppendingString:binary];
}
NSString *hex = @"";
for (int i=0; i<binary.length; i+=4) {
NSString *key = [binary substringWithRange:NSMakeRange(i, 4)];
NSString *value = [binaryDic objectForKey:key];
if (value) {
hex = [hex stringByAppendingString:value];
}
}
具体的还是请看代码吗。
https://github.com/976971956/BaseIsInstalledIn.git