IOS-Exception Handling

Source: Internet
Author: User

1. exception preface Exception Handling and capturing in iOS is not as common as in other languages. I believe many iOS programmers know that it is more often used for memory detection and analysis, detects memory problems. The app crash is not because of memory. At this time, we can fully capture Common exceptions. After the capture, it is sent to the server, and a user error is prompted. Or, the system rolls back to the server to Prevent the application from crashing. 2. Exception Handling 2. 1. When you know the specific location where an error occurs occasionally and cannot be solved, you can use the try in xcode to avoid program crash. 2. I don't know the specific location, and I'm listening for common errors. We need to use two frameworks to send them to the server. The use of the two third-party frameworks can be found on github according to specific situations. uncaughtExceptionHandler can detect Common Errors and kindly prompt users such as 1. crash caused by problems such as NSArray, NSDictionary, NSString, and KVC. 2. Solve the problem that NSObject merge mselector cannot find the selector. Method of use: 1. First, you must use InstallUncaughtExceptionHandler () in appDelegate for listening. 2. Add the UncaughtExceptionHandler class iOS SDK to provide the function NSSetUncaughtExceptionHandler for exception handling. However, memory access errors and repeated release errors cannot be handled because the SIGNAL sent by these errors. Therefore, we need to handle these SIGNAL effects which can be detected in the Demo. 2. The DurexKit Security Toolkit can prevent program crashes, and you can write a segment logic to intercept exception information in the background and send it to the server for easy running of the program. Disadvantage: the user does not have a prompt to perform rollback. How to Use: import # import "DurexKit. h "When Category is used, the method can be executed only after the parameter is determined, and then the native throwing exception method is replaced. Therefore, you do not need to modify any existing code. Only the header file of the import toolkit is used, to solve some exceptions. 1. flashback caused by problems such as NSArray, NSDictionary, NSString, and KVC. 2. Solve the problem that NSObject merge mselector cannot find the selector. 1. Add the folder "DurexKit" to the project; 1.2. # import "DurexKit. h" 1. 3. You do not need to modify any code in the project.

Related Article

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.