ios - How do map the json data if user enter incorrect detail? -


my question implementation working when user enter correct credential, issue come when user enter incorrect details:

my request map objects:

alamofire.request(.post, urlstring, parameters: params, encoding: .json, headers: headers).responseobject(keypath: "data") { (response: response<user, nserror>) in {  } 

below json response when user entered incorrect credentials:

{      "success": "false",      "message": "the user name or password incorrect.",      "data": null } 

error when user enter incorrect details: error :

result : failure: error domain=com.alamofire.error code=-6004 "objectmapper failed serialize response." userinfo={nslocalizedfailurereason=objectmapper failed serialize response.}

please guide , suggest according implementation.

there tow ways handle :

1- manually check fields data before passing alamofire request. : data not nil, number of characters , data type.

2- can use library "swiftvalidator" . usefull library handle user input form. https://github.com/bilawal-liaqat/swiftvalidator

i'll recommend use library. has data type built-in handle user input.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -