Common methods of Foundationのnsarray

Source: Internet
Author: User

Nsarray
//creates an array with the specified argumentsNsarray *array = Nsarray alloc] initwithobjects:@" One",@" Both",@"three",@" Four", nil]; Nsarray*array = @[@" One",@" Both",@"three",@" Four"];//copy data from one array to anotherNsarray *array1 =[Nsarray Arraywitharray:array]; Nsmutablearray*mutablearray =[Nsmutablearray Arraywitharray:array]; //string splits the fractional group by the specified characterNsarray *array = [stringComponentsseparatedbystring:@","];//Inverse array Merge stringNSString *string= [Array componentsjoinedbystring:@","]; //The number of objects in the array;NSLog (@"%ld", Array.count)//[Array count];//gets the object at the specified index; NSLog (@"%@", [array Objectatindex:2]);
Nsmutablearray
//allocating capacity to an arrayNsarray *array = [Nsmutablearray arraywithcapacity: -]; //add an object at the end of an arrayNsmutablearray *array = [Nsmutablearray arraywithobjects:@" One",@" Both",@"three", nil]; [Array AddObject:@" Four"]; //deletes the specified index object in the array[Array Removeobjectatindex:1];

Common methods of Foundationのnsarray

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.