Alamofire仅在设备中崩溃

时间:2015-07-25 01:10:52

标签: ios alamofire

我正在使用Alamofire.download来获取我的图片文件。它在模拟器中运行良好,但在设备中崩溃。

以下是我的下载功能

func downImage(url : String, success: (image: UIImage?)-> Void, failure: ()-> Void)
{
    if let image = self.cacheImage(url.lastPathComponent)
    {
        success(image: image)
    }else
    {
        let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, domain: .UserDomainMask)
        Alamofire.download(.GET, url, destination: destination)
            .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
                println(totalBytesRead)

                log.debug("\(totalBytesRead)/\(totalBytesExpectedToRead)")
            }
            .response { (request, response, responseData, error) -> Void in

                if response?.statusCode == 200
                {

                    if let image = self.cacheImage(response?.suggestedFilename)
                    {
                        success(image: image)
                    }else
                    {
                        success(image: nil)
                    }


                }else
                {
                    failure()
                }

        }
    }
}

崩溃发生在Request.swift。

/**
    Resumes the request.
*/
public func resume() {
    task.resume()
}

崩溃消息是

  

EXC_BAD_ACCESS

0 个答案:

没有答案