AFNetworking Error Domain = com.alamofire.error.serialization.response Code = -1011"请求失败:未找到(404)"

时间:2016-04-06 05:16:20

标签: ios swift afnetworking

在AFNetworking中出错。错误Domain = com.alamofire.error.serialization.response Code = -1011 成功块永远不会被召唤。 这个错误意味着什么...我没有使用Alamofire然后为什么它会给出错误,如

  

Domain = com.alamofire.error.serialization.response Code = -1011

class HTTPClient: NSObject {

class var sharedInstance: HTTPClient {
    struct Singleton {
        static let instance = HTTPClient()
    }
    return Singleton.instance
}

func postFileWithParameter(path:String,parameters:[String:String],profilePic : UIImage?, success : (AnyObject?) -> () , failure : (NSError?) -> ()) {

    let manager = AFHTTPRequestOperationManager()
    manager.responseSerializer = AFHTTPResponseSerializer()
    manager.POST(path, parameters: parameters, constructingBodyWithBlock:
        {  (formData) -> Void in

            if let ppic = profilePic , data = UIImageJPEGRepresentation(ppic,1.0) {
                formData.appendPartWithFileData(data, name: "image", fileName: "Unknown.jpg", mimeType: "image/jpeg")
            }
        }
        , success: {
            (operation,response) -> Void in
            print("success block")
            do {

                success(try NSJSONSerialization.JSONObjectWithData(response as! NSData, options: .MutableLeaves))
            } catch {

            }
        }) {
            (operation,error) -> Void in
            failure(error)
    }        
}

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()      

    let URL = "http://52.37.13.12/user/"

    guard   let image = UIImage(named: "Unknown") else {
        return }

    let parameters:[String:String] = ["linkedin_id ":"125464563","name":"rahul","email":"cxv@gmail.com","job":"dsf","city":"chd","company":"xyz","profile_url":"http:\\www.linkedin.com","otherdata":"df"]               
  HTTPClient.sharedInstance.postFileWithParameter(URL, parameters: parameters, profilePic: image, success: {
        response in
        print(response)

        }, failure: {
            error in
            debugPrint(error)
    })
}
}

0 个答案:

没有答案