Inline static NSData * encodeBCD (NSString * value) {// NSString * value = @ "123456"; NSMutableData * vdata = [[NSMutableData alloc] init]; __uint8_t bytes [1] = {6}; [vdata appendBytes: & bytes length: 1]; nsange range; range. location = 0; range. length = 1; for (int I = 0; I <[value length];) {range. location = I; NSString * temp = [value substringWithRange: range]; int _ intvalue1 = [temp intValue]; _ intvalue1 = _ intvalue1 <4; range. location = I + 1; temp = [value substringWithRange: range]; int _ intvalue2 = [temp intValue]; int intvalue = _ intvalue1 | _ intvalue2; bytes [0] = intvalue; [vdata appendBytes: & bytes length: 1]; I + = 2;} bytes [0] = 255; [vdata appendBytes: & bytes length: 1]; bytes [0] = 255; [vdata appendBytes: & bytes length: 1]; bytes [0] = 255; [vdata appendBytes: & bytes length: 1]; bytes [0] = 255; [vdata appendBytes: & bytes length: 1]; return [vdata autorelease];}