2 has an array with 13 elements in the array, first grouping the array, each of the 3 elements as a group, divided into groups, and finally using an array to manage these groupings uniformly. (To create an array dynamically).

Source: Internet
Author: User

[CPP]View Plaincopyprint?
  1. Nsmutablearray *arr = [[Nsmutablearray alloc] init];
  2. For (int i = 0; i < i++) {
  3. [Arr addobject:[nsstring stringwithformat:@"damo%d", I]];
  4. }
  5. NSLog (@"%@", arr);
  6. Nsmutablearray *bigarr = [[Nsmutablearray alloc] initwithcapacity:1];
  7. Nsmutablearray *smallarr = nil;
  8. For (int i = 0; i < [arr count]; i++) {
  9. if (i% 3 = = 0) {
  10. //Just read 0 3 6 9 12 to open up space to store the next three elements
  11. Smallarr = [[Nsmutablearray alloc] initwithcapacity:1];
  12. //Add a decimal group to a large array for management
  13. [Bigarr Addobject:smallarr];
  14. }
  15. [Smallarr Addobject:[arr objectatindex:i];
  16. }
  17. NSLog (@"%@", Bigarr);</span>

2 has an array with 13 elements in the array, first grouping the array, each of the 3 elements as a group, divided into groups, and finally using an array to manage these groupings uniformly. (To create an array dynamically).

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.