下载: Alamofire


import UIKit
import Alamofire

protocol DownloadAlamofireDelegate: NSObjectProtocol {

    
    func DownloadAlamofire(downloader: DownloadAlamofireHand ,  failWithError error: NSError)
    func DownloadAlamofire(downloader: DownloadAlamofireHand , finishWithData data: NSData)
    
    
    
}




class DownloadAlamofireHand: NSObject {

    var delegate: DownloadAlamofireDelegate?
    
    
    
    
    func alamofireDownloadWithUrlString(urlString: String){
    
        
        let request = Alamofire.request(.GET, urlString)
        
        
        request.responseData { (response ) in
            
            
            switch response.result {
            
                
                case .Failure(let error):
                
                    self.delegate?.DownloadAlamofire(self, failWithError: error)
                
                                case .Success:
                
                    self.delegate?.DownloadAlamofire(self, finishWithData: response.data!)
                
                    }            
        }
    
    }
    
}


















你可能感兴趣的:(下载: Alamofire)