2014-02-15 159 views
2

我正在与iOS中央处理器进行通信,以便与BLE外围设备进行通信。CoreBluetooth读取/写入数据

使用LGBluetooth框架https://github.com/DavidSahakyan/LGBluetooth

的方法得到

 
     [LGUtils readDataFromCharactUUID:aCharactId 
           seriveUUID:aServiceId 
           peripheral:peripheral 
           completion:^(NSData *data, NSError *error) { 
            NSLog(@"Data : %s Error : %@", (char *)[data bytes], error); 
           }]; 

它输出 “1234567890”

我需要转换(字符*)[数据字节]来NSInteger的。 当我得到它

 
     NSInteger dataInt = [data bytes]; 

我得到2013527536,但该值是1234567890的周侧

+0

上面的链接不起作用 – DAMM108

回答

1

尝试做这样的事情:

NSInteger dataInt = atoi((const char*)[data bytes]); 
+0

我用atol((const char *)[data bytes]) – l0gg3r