IOS array out-of-bounds Solution

Source: Internet
Author: User

IOS array out-of-bounds Solution

The so-called array is out of bounds, that is, if your total number of subscripts is now 32, then you execute another method in the next second to wake up from 50 data records, assign values, filter, and so on. At this time, the number of 32 50 data records has not been requested, and the array may be out of bounds. the crash information is probably like this-[_ NSArrayI objectAtIndex:]: index 100 beyond bounds [0 .. 9] 'specific solution we usually choose to make a judgment column for the array, such as return nil;

Although it is possible in most cases, it is not rigorous, if you set an nstray for event loop execution and you have a large amount of data, the number of arrays is always changing columns, such as the pins on the map. You need to perform the NSArray or NSmutableArray yourself. one method extension replaces [_ performancearray objectAtIndex: indexPath. row] This method.

The following is a method from the perspective of a great god. It is very helpful for me to try it!

Replace objectAtIndex with objectAtIndexCheck.

 

 

You can give it a try. You will always learn the Logic Thinking of the great God as you keep improving.

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.