iosobjective-cnsurlconnectionnshttpurlresponse

iOS url response bool


net web service that returns true or false but i don't know how to catch that response in my IOS App.

My service updates data in a database and i know it works the data gets updated it's catch the response that is the problem, i like to know so i can tell the user if something went wrong.

For those of you that know c# its a bool method, just simple try catch and return true or false.

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    //What to write here to catch my true or false
    if(response) {
       //true
    } else {
       //false
    }
}

Thank you for your help


Solution

  • You should implementconnection:didReceiveData: to get and save NSData and ā€“ connectionDidFinishLoading: where you can interpret received data as BOOL.

    basically didReceiveResponse: only get to you know about server response to your request not the entire answer.