0
WatchConnectivity를 통해 Apple Watch에서 쌍방향 iPhone으로 데이터 파일을 보내려고합니다. 내 코드는 다음과 같습니다 :WatchConnectivity 및 WCSession을 통해 전송 대기열에 파일이 없습니다.
let data = try? JSONSerialization.data(withJSONObject: self.storedData, options : .prettyPrinted)
let str = String(data: data!, encoding: String.Encoding.utf8)
print(str)
var fileName = ""
let tempDirectory = NSTemporaryDirectory()
fileName = tempDirectory + "test.json"
if self.fileManager.createFile(atPath: fileName, contents: data
, attributes: nil) {
print("New file creation went through!")
}
if self.fileManager.fileExists(atPath: fileName) {
print("File created @ \(fileName)")
} else {
print("Something wrong when creating file @ \(fileName)")
}
var fileTransferString = "file://"
fileTransferString += fileName
let url = URL(string: fileTransferString)
self.session.transferFile(url!, metadata: nil)
print("\(self.session.outstandingFileTransfers.count) files in the transfer queue!")
내가하는 메시지를 가지고 있지만 "파일 생성을 @ ...", 마지막 줄에 "프린트"에 의해 다음과 같은 메시지가 항상 "전송 큐에 0 파일!" 그 과정에서 어떤 물건도 시작하지 못하거나 아무 것도 찾지 못했습니다. 파일이 생성되었지만 "session.transferFile"함수가 전달되지 않은 것처럼 보입니다.
문제가있는 부분과 해결 방법에 대한 힌트를 누군가도 얻을 수 있습니까?
감사합니다.
폴