Details about nsarray

Source: Internet
Author: User
-(Nsuinteger) count; get the number of objects in nsarray

-(ID) objectatindex :( nsuinteger) index; get the object at the index position in nsarray

-(Nsarray *) arraybyaddingobject :( ID) anobject; add anobject to the end of the array-(nsarray *) arraybyaddingobjectsfromarray :( nsarray *) otherarray;

Add the objects in the otherarray array to the end of the stolen Array


-(Nsstring *) componentsjoinedbystring :( nsstring *) separator;

The elements in the array are separated by separator to form an nsstring.

-(Bool) containsobject :( ID) anobject;

Determine whether the anobject is in the array


-(Nsstring *) description;

Description of objects in the array, which can output objects in the array (to be further determined)


-(Nsstring *) descriptionwithlocale :( ID) locale;-(nsstring *) descriptionwithlocale :( ID) locale indent :( nsuinteger) level;-(ID) firstobjectcommonwitharray :( nsarray *) otherarray;

Returns the first same object in nsarray and otherarray.


+ (ID) arraywithobjects :( constid []) Objects count :( nsuinteger) CNT;
Nsstring * string [5]; string [0] = @ "first"; string [1] = @ "second"; string [2] = @ "third "; string [3] = @ "forth"; nsarray * array = [nsarray arraywithobjects: String count: 3]; output result: First, Second, Third
-(Void) getobjects :( ID _ unsafe_unretained []) Objects range :( nsange) range; extracts the data corresponding to the nsange from the array objects, and the data in the range indicates the data from the range. location starts to range. length Element
NSArray *mArray = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil];id *objects;NSRange range = NSMakeRange(2, 3);objects = malloc(sizeof(id) * range.length);[mArray getObjects:objects range:range];for (NSInteger i = 0; i < range.length; i++){    NSLog(@"objects: %@", objects[i]);}free(objects);
-(Nsuinteger) indexofobject :( ID) anobject inrange :( nsange) range;

The index position of the anobject within the range in the entire array

-(Nsenumerator *) objectenumerator;

Obtain nsenumerator of the array in sequence

-(Nsenumerator *) reverseobjectenumerator;

Returns the nsenumerator of the array in reverse order.

NSEnumerator *enumerator = [mArray objectEnumerator];id object;while((object = [enumerator nextObject])){    NSLog(@"object:%@",object);}

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.