Use of Nspredicate

Source: Internet
Author: User

Nsarray * arrayfilter = [nsarray arraywithobjects:@ "pict", @ "Blackrain" , @ "IP", Nil];

nsmutablearray *arraycontents = [nsmutablearray Arraywithobjects:@ "I am a picture." @ "I am a guy", @ "I am Gagaga", @ "ipad", @ "iphone", nil ];

int i = 0;

Nsinteger count = [Arrayfilter count];

for (i = 0; i < count; i + +)

{

nsstring * arrayitem = (nsstring *) [Arrayfilter objectatindex: i];

nspredicate *filterpredicate = [nspredicate predicatewithformat:@ "Self CONTAINS%@" , Arrayitem];

NSLog (@ "Filtered array with filter%@,%@", Arrayitem, [arraycontents filteredarrayusingpredicate: Filterpredicate]);

}

nsarray *arrayfilter01 = [nsarray arraywithobjects:@ "ABC1", @ "ABC2", Nil];

nsmutablearray *arraycontent01 = [nsmutablearray arraywithobjects:@ "A1" , @ "ABC1", @ "ABC4" , @ "ABC2", Nil ];

nspredicate * thepredicate = [nspredicate predicatewithformat:@ ' not ' (self in%@), ARRAYFILTER01];


[arrayContent01 filterusingpredicate: thepredicate];

NSLog (@ "result%@", ArrayFilter01);


This article from "Shenzhen Lian City Tong technology company" blog, declined reprint!

Use of Nspredicate

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.