美文网首页
NSPredicate Demo

NSPredicate Demo

作者: punisher | 来源:发表于2015-09-15 16:38 被阅读98次

    import <Foundation/Foundation.h>

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

        NSMutableArray *array =[NSMutableArray arrayWithObjects:@"Bill",@"Ben",@"Chris",@"Melissa",nil];
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'C'"];
        //SELF contains[c] 'C'
        
        NSArray *arrayB = [array filteredArrayUsingPredicate:predicate];
        
        //NSLog(@"%ud",[arrayB count]);
        
        for (int i=0;i<arrayB.count;i++){
            NSLog(@"%@",[arrayB objectAtIndex:i]);
        }
        
        // insert code here...
        NSLog(@"Hello, World!");
    }
    return 0;
    

    }

    相关文章

      网友评论

          本文标题:NSPredicate Demo

          本文链接:https://www.haomeiwen.com/subject/unlmcttx.html