Common crash problems in iOS, crash log analysis, and ioscrash Log Analysis

Source: Internet
Author: User

Common crash problems in iOS, crash log analysis, and ioscrash Log Analysis

First, iOS common crash Problems

1. Insert an empty Element

Crash when an empty element is inserted for variable objects such as NSMutableArray, NSMutableDictionary, and NSMutableSet
The correct method is to add judgment. The sample code is as follows:
NSDictionary * dic;
NSMutableArray * arr = [NSMutableArray new];
If (dic ){
[Arr addObject: dic];
}
NSLog (@ "% @", arr );
Condition for non-null addition: if (dic)
2. Cross-border and pointer null judgment
This type of crash is similar to C ++. For NSArray objects, when calling objectAtIndex, you must determine whether to cross the border.
Pointer OC is rarely used in development. If you want to use it, you must determine whether it is null.

3. After NSNotification is added, removeObserve must be used in the dealloc function.

4. Create an NSTimer scheduled task. In the dealloc function, the task must be invalidate.

5. When you initiate a network request in the Code and set the proxy, you must release the change proxy in the dealloc function because there is time for network access, when the network data is returned and the proxy object is no longer in use, crash occurs.

6. Use APIs of the higher version. Because each app has an iphone version, when the user machine uses a lower version of the system, it will crash

7. If the memory usage is too large, crash will occur when two memory warnings are received. Therefore, the released items must be released in time.

8. The crash caused by multi-thread concurrent operations. In a multi-concurrency environment, if one thread has deleted the data and the other thread has accessed the data, it will inevitably crash because the data is not there, therefore, the locking mechanism must be used to solve the problem.

9. Call a nonexistent class or Method

If (NSClassFromString (@ "MFMailComposeViewController") respondsToSelector:


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.