[Tips] Nsarray Use Tips

Source: Internet
Author: User

Nsarray believe that the development of iOS almost every day to use, in some cases, we need to go to the array of weight and sequencing, the general wording is nothing but the first traversal, and then processing the results, in fact, we have a more convenient way to fix.

Fast array de-weight

Nsarray *[email protected][@ "One", @ "one", @ "one"];

Tmparray = [Tmparray valueforkeypath:@ "@distinctUnionOfObjects. Self"];

In this way, we have already completed the Tmparray of the array, and we have removed the duplicate @ "one" inside the resulting.

Array Fast Reverse

Nsarray *tmparray = @[@ "One", @ "one", @ "three"];

Tmparray = Tmparray. Reverseobjectenumerator. AllObjects;

Very simple, only with one line of code, completed the reverse operation, the resulting tmparray is @[@ "three", @ "Two", @ "one"].

[Tips] Nsarray Use Tips

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.