将NSData的块转换为NSString

时间:2014-04-10 22:15:28

标签: objective-c bluetooth-lowenergy core-bluetooth

我是iOS的新手,我试图传输一个文件。当发送设备是iphone 5c到iPad时,此代码工作正常,但尝试通过Bluetooth4.0从ipad发送到Iphone时发送NULL

NSData *chunk = [NSData dataWithBytes:self.dataToSend.bytes+self.sendDataIndex length:amountToSend];
NSLog(@"Chunk%@",chunk); 
didSend = [self.peripheralManager updateValue:chunk forCharacteristic:self.transferCharacteristic onSubscribedCentrals:nil];
NSString *stringFromData = [[NSString alloc] initWithData:chunk encoding:NSUTF8StringEncoding];
NSLog(@"Sent: %@", stringFromData);

此外,iphone在通知开始时获得以下输出

CBCharacteristic: 0x15da1d90 UUID = EB6727C4-F184-497A-A656-76B0CD5C633A, Value = (null), Properties = 0x10, Notifying = YES, Broadcasting = NO

0 个答案:

没有答案