Responseserializer 'Cannot Call Value of Non-Function Type 'Nshttpurlresponse'' with Swift 3

ResponseSerializer 'cannot call value of non-function type 'NSHTTPURLResponse?'' with Swift 3

You need to mark your completionHandler as @escaping.

Alamofire: Cannot call value of non-function type 'NSHTTPURLResponse?'

If this is, as you say, working fine in the other file a couple of suggestions come to mind.

  • Mark the class you are extending as public. (Swift classes are internal by default.)
  • Open the document inspector pane on the right of your class, make sure your target membership includes the target you are compiling for.

Let me know if your issue still persists and I will investigate further.

Cannot call value of non-function type 'HTTPURLResponse?'

Instead of using response,data,error independently alamofire provides data which involve all of these parameters

Solution:

Alamofire.request(imageURL)
.validate(contentType: ["image/*"])
.response { data in

we can access error on data : data.error or response by data.response

Cannot call value of non-function type '((AnyObject) - AnyObject?)!' - Swift 3

The syntax has changed from:

let x = myData.objectForKey("myKey")

to:

let x = myData.object(forKey:"myKey")

in Swift 3.

Example:

var x : AnyObject = ["Hello" : "Goodbye"] as AnyObject
x.object(forKey:"Hello")

Alamofire 3-4 trouble with Reponse & ResponseSerializer Swift 3.0

Bro try below code see:

func responseListArray(_ completionHandler: @escaping (Response<ListWrapper>) -> Void) -> Self {
let responseSerializer = ResponseSerializer<ListWrapper> { request, response, data, error in

guard error == nil else
{
return .failure(error!)
}
guard let responseData = data else {
return .failure(AFError.responseSerializationFailed(reason: .inputDataNil))

}

let JSONResponseSerializer = Request.JSONResponseSerializer(options: .allowFragments)
let result = JSONResponseSerializer.serializeResponse(request, response, responseData, error)

switch result {
case .success(let value):
let json = SwiftyJSON3.JSON(value)
let wrapper = ListWrapper()

var allList:Array = Array<List>()

wrapper.totalCount = json["favorite_count"].intValue

// print(json)
let results = json["items"]
// print(results)
for jsonList in results
{
//print(jsonList.1)

let list = List(json: jsonList.1, id: Int(jsonList.0) )
if (list.posterPath == "")
{
continue
}
else
{
//print(movies.posterPath)
allList.append(list)
}

}
wrapper.results = allList
return .success(wrapper)
case .failure(let error):
return .failure(error)
}
}

return response(responseSerializer: responseSerializer,completionHandler: completionHandler)
}

Alamofire extension for showing photos in collection view (SWIFT 2.0)

Alamofire 2.0 is redesigned, so take a look here: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%202.0%20Migration%20Guide.md

Your code would look something like this:

cell.request = Alamofire.request(.GET, imageURL!)
.responseData { request, _, result in
if let error = result.error as? NSError {
//handle error
return
}else{

//Check if image is correct
//result.value
}
}

It seems that .responseImage no longer exists.



Related Topics



Leave a reply



Submit