iOS Development--Error Summary & exception capture

Source: Internet
Author: User

Exception snapping

1 Sometimes the application crashes, and the log output information is too small to locate the problem, this is the most headache, especially when it is very tired, has not been able to remember what has just changed, this is called non-resistance. 2 3 工欲善其事, its prerequisite, the following method can give more information, let you see the sequence of stack execution, where the collapse, you can probably give a thought to determine the crux of the problem. 4 5 before the APPDELEGATE.M class implementation, add:6 7  8 9 voidUncaughtexceptionhandler (NSException *exception) {Ten      One     //getting exception-related information ANsarray *callstacksymbols =[Exception callstacksymbols]; -NSString *callstacksymbolstr =[Callstacksymbols componentsjoinedbystring:@ - ]; theNSString *reason =[Exception reason]; -NSString *name =[exception name]; -      -     //Get system Current time +NSDate * Date =[NSDate Date]; -NSDateFormatter * Dateformatter =[[NSDateFormatter alloc] init]; + [dateformatter Setdateformat: @yyyy years mm month DD day HH hours mm minutes ss seconds]; ANSString * Datestr =[Dateformatter stringfromdate:date]; at      -NSLog (@ System Current time is:%@  - , datestr); -NSLog (@ exception name:%@  - , name); -NSLog (@ exception Reason:%@  in , reason); -NSLog (@ Stack flag:%@  to , callstacksymbolstr); + } -  the   *  $  Panax Notoginseng Add the following statement to the application startup method implemented by the APPDELEGATE.M class, and set the exception callback function for the system to the above declaration, as described in the "IOS Foundation Framework Overview Document: Constants, data types, frameworks, functions, publishing declarations": -  the @implementationappdelegate +  A-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions { the      +Nssetuncaughtexceptionhandler (&Uncaughtexceptionhandler); -     

iOS Development--Error Summary & exception capture

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.