我正在制作一个应用程序,通过MC发送视频,didStartReceivingResourceWithName被正确调用。与该回调相关联的NSProgress对象达到101.0%,然后didFinishReceivingResourceWithName从未被调用。你有什么想法吗?以下是每个代码:
func session(session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, withProgress progress: NSProgress) {
print("Did start receiving resource")
dispatch_async(dispatch_get_main_queue()){
self.progressTimer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "progressManager", userInfo: nil, repeats: true)
self.progress = progress
}
}
func session(session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, atURL localURL: NSURL, withError error: NSError?) {
dispatch_async(dispatch_get_main_queue()){
self.status.text = "Recieved!"
}
self.progressTimer.invalidate()
let destinationPath =
NSURL(fileURLWithPath: NSTemporaryDirectory()).URLByAppendingPathComponent("movie.mov")
let fileManager: NSFileManager = NSFileManager.defaultManager()
do{
try fileManager.moveItemAtURL(localURL, toURL: destinationPath)
}
catch let error as NSError {
print(error)
}
print("Did finish receiving resource")
}