画像があり、Bluetooth 経由で別のデバイスに送信する必要があります。データは次のとおりです。
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 がどのように機能するかを理解するのに問題があります。使用する必要がある URL とその作成方法を誰かに説明してもらえますか?