Debugging IOS应用内购买从不离开活动状态

Debugging IOS应用内购买从不离开活动状态,debugging,ios7,in-app-purchase,swift,Debugging,Ios7,In App Purchase,Swift,我在swift中使用托管内容进行了应用内购买。没有错误。我的下载队列如下: func paymentQueue(queue: SKPaymentQueue!, updatedDownloads downloads:[AnyObject]){ for download:AnyObject in downloads { if let down:SKDownload = download as? SKDownload { switch down.dow

我在swift中使用托管内容进行了应用内购买。没有错误。我的下载队列如下:

func paymentQueue(queue: SKPaymentQueue!, updatedDownloads downloads:[AnyObject]){
    for download:AnyObject in downloads {
        if let down:SKDownload = download as? SKDownload  {
            switch down.downloadState {
            case .Active:
                NSLog("Active %@ %@",down.progress,down.timeRemaining)
                break
            case .Cancelled:
                NSLog("%@","download cancelled")
                break
            case .Failed:
                NSLog("%@","download failed")
                productTitle.text = "Download Failed"
                break
            case .Finished:
                NSLog("%@","download finished")
                var source = down.contentURL.relativePath
                var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
                var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))

                if !dict.objectForKey("Files"){
                    SKPaymentQueue.defaultQueue().finishTransaction(down.transaction)
                    return
                }



                if let arr = dict["Files"] as? [String] {
                    for file in arr {
                        let content:String = source.stringByAppendingPathComponent("Contents").stringByAppendingPathComponent(file)
                        self.copyPathToDocsFolder(source,target:content)
                    }
                }

                SKPaymentQueue.defaultQueue().finishTransaction(down.transaction)
                NSLog("Download Complete");
                productTitle.text = "Download Complete";

            case .Paused:
                    NSLog("%@","SKDownloadStatePaused")
                    break
            case .Waiting:
                    NSLog("%@","SKDownloadStateWaiting")
                    break
            default: break
            }
        }
    }
}
var source = down.contentURL.relativePath
var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))
这是我的copy方法,它永远不会被调用

func copyPathToDocsFolder(source:String,target:String) {
    NSLog("Copy function called")
    let filemgr:NSFileManager = NSFileManager.defaultManager()
    let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String

    let docsDir = dirPaths;

    let targetPath = docsDir.stringByAppendingPathComponent(target)

    var error:NSError?


    if (filemgr.copyItemAtPath(source, toPath:target, error:&error)) {
        NSLog("Great Success");
    }
    else {
        NSLog("Error copying file:");
    }
}
var source = down.contentURL.relativePath
var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))

我在一台真正的、有许可证的、配置好的设备上工作。当下载委托开始时,在委托的switch语句的第一种情况下,Active跟踪,但下载进度和剩余时间均为零。有什么想法吗?我真的不知道如何调试它,因为没有错误。

在case.Finished语句中

var source = down.contentURL.relativePath
var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))
应该是

var source = down.contentURL.relativePath
var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))
var source = down.contentURL.relativePath                    
var dict =   NSMutableDictionary(contentsOfFile: source.stringByAppendingPathComponent("ContentInfo.plist"))
NSBundle.mainBundle()。没有理由呆在那里

var source = down.contentURL.relativePath
var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var dict = NSDictionary(contentsOfFile:source.stringByAppendingPathComponent(path))