Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 36', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Example 1 Location-Based Search 319 NSLog connection didReceiveResponse setLength 0 Next you will implement the connection didReceiveData method. The connection calls this method each time it receives a chunk of data so you simply append the received chunk to your responseData buffer Available for download on - void connection NSURLConnection connection didReceiveData NSData data NSLog connection didReceiveData Append the received data to our responseData property appendData data Now you need to implement connectionDidFinishLoading. This method runs when the connection has finished loading all of the requested data. Here you convert the response data to a string clean up the connection and call the method that you will write to parse the XML Available far download on - void connectionDidFinishLoading NSURLConnection connection NSLog connectionDidFinishLoading Convert the data to a NSString responseString NSLog Response String string and log the response string NSString alloc initWithData encoding NSUTF8StringEncoding n responseString responseString release connection release self parseXML Finally you will implement the connection didFailWithError method to log that an error occurred. Remember that you will want to provide some more robust error handling and reporting 320 CHAPTER 11 INTEGRATING WITH WEB SERVICES in a production application. You will also probably want to give the user some feedback as to why the error occurred. Here is the implementation o Available for download on - void connection NSURLConnection connection didFailWithError NSError error NSLog connection didFailWithError NSLog error localizedDescription connection release Note that you don t have to call a web service or a URL asynchronously but it is certainly my recommendation that you do so. .