Common crash problems in iOS and crash log analysis

Source: Internet
Author: User

First, iOS common crash problem

1. Inserting empty elements

For variable objects such as Nsmutablearray, Nsmutabledictionary, Nsmutableset, and so on, when inserting an empty element crash
The correct approach is to add a judgment, sample code is as follows:
Nsdictionary *dic;
Nsmutablearray *arr=[nsmutablearray New];
if (DIC) {
[Arr Addobject:dic];
}
NSLog (@ "%@", arr);
Add non-NULL condition: if (DIC)
2. Cross-border and pointer null judgment
This crash is similar to C + +, for objects of type Nsarray, when calling Objectatindex, be sure to determine whether they are out of bounds.
The pointer oc is not used much in development, if you want to use it, you must also determine whether it is empty

3, after adding nsnotification, in the Dealloc function, must be removeobserve

4, create Nstimer Scheduled Tasks, in the Dealloc function, must be invalidate

5, when you launched a network request in the code, and set the proxy, then in the Dealloc function must release the change agent, because the network access is time, when the network data back to find the proxy object is not, this time will occur crash

6, use the high version of the API, because each app has the use of the iphone version, when the user machine is using the lower version of the system, if you encounter the high version of the API will certainly crash

7, take up too much memory, after receiving two times memory warning will be crash, so the release of Things must be released in time

8, multi-threaded concurrency caused by the crash, in a multi-concurrency environment, if a thread has deleted data, another thread to access, because the data is not necessarily crash, so must be through the locking mechanism to solve the problem

9. Call a class or method that does not exist

if (nsclassfromstring (@ "Mfmailcomposeviewcontroller")) Respondstoselector:


Common crash problems in iOS and crash log analysis

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.