Use try and catch to catch errors in iOS development.

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/remote_roamer/article/details/7105776
    1. The code that throws the error
      [CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
        1. Throws an error if the returned message is an error message
        2. if ([outparams Count] <= 0)
        3. {
        4. [NSException raise:@"WebService error" format:@"%@", Returnjson4soap];
        5. }
    2. Capturing the error code in the call
      [CPP]View Plaincopy
      1. Parsing the Cusotmerdetail object from the SOAP message
      2. @Try
      3. {
      4. Customerdetail = [[[Soaprtnjsonparser alloc] init] parse2customerdtail:[returnsoapxml datausingencoding: Nsutf8stringencoding]];
      5. }@catch (NSException * e) {
      6. NSLog (@"Exception:%@", e);
      7. Uialertview * Alert =
      8. [[Uialertview Alloc]
      9. initwithtitle:@"Error"
      10. Message: [[NSString alloc] initwithformat:@"%@", E]
      11. Delegate:self
      12. Cancelbuttontitle:nil
      13. otherbuttontitles:@"OK", nil];
      14. [Alert show];
      15. [Alert release];
      16. return;
      17. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.