我有一张图片,我需要通过蓝牙将其发送到另一台设备。数据是这样的:
NSData *Recording = [NSData dataWithContentsOfFile:myFilePath];
NSString* str = [NSString stringWithFormat:@"%@.ext", button.titleLabel.text];
myDictionary = [[NSMutableDictionary alloc] init];
[myDictionary setObject:str forKey:@"fileName"];
[myDictionary setObject:@"Recording" forKey:@"fileType"];
[myDictionary setObject:Recording forKey:@"FileData"];
NSData* myData = [NSKeyedArchiver archivedDataWithRootObject:myDictionary];
我需要使用以下方法发送 myData 或 myDictionary:
progress = [session sendResourceAtURL:anUrl withName:[imageUrl lastPathComponent] toPeer:peerID withCompletionHandler:^(NSError *error) {
// Implement this block to know when the sending resource transfer completes and if there is an error.
if (error) {
NSLog(@"Send resource to peer [%@] completed with Error [%@]", peerID.displayName, error);
}
else {
// Create an image transcript for this received image resource
}
}];
如您所见,我必须在 url 处发送资源,而接收者将在“url”处接收资源,并且我必须从该 url 获取 NSMutabledictionary。基本上我必须发送这个 myDictionary 但我无法弄清楚 url 是如何工作的。谁能解释我必须使用什么网址以及如何创建它?