Array copy element number join find query location

Source: Internet
Author: User

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

@autoreleasepool {

Array

Quickly create an array

Nsarray *[email protected][@ "MON", @ "TUE", @ "WED", @ "THU", @ "FRI", @ "SAT", @ "SUN"];

NSLog (@ "%@", week);

Create an empty array

Nsarray *arr=[[nsarray Alloc]init];

Nsarray *arr1=[nsarray Array];

Note Array connection uses nil (null) to end non-delete

Nsarray *arr2=[nsarray arraywithobjects:@ "Das", @ "DSA", nil];

Nsarray *arr3=[nsarray arraywithobject:@ "B"];

Copy

Nsarray*new=[nsarray Arraywitharray:week];

NSLog (@ "%@", new);

Gets the number of elements in the array

Nsinteger count=[new Count];

NSLog (@ "Number:%ld", count);

Accessing elements within an array based on a number of subscripts

NSString *str=[new Objectatindex:1];

NSLog (@ "%@", str);

Add an element to an array

Nsarray *add=[new arraybyaddingobject:@ "SDFG"];

NSLog (@ "%@", add);

Connection

NSString *new1=[new componentsjoinedbystring:@ ","];

NSLog (@ "%@", New1);

Determine if an array contains a single object

BOOL resu=[new containsobject:@ "THU"];

NSLog (@ "%d", resu);

Querying the position of an object in an array

Nsinteger index=[new indexofobject:@ "THU"];

NSLog (@ "%d", (int) index+1);

Gets the last element of the array

NSString *lastring=[new Lastobject];

NSLog (@ "%@", lastring);

}

return 0;

}

Array copy element number join find query location

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.