zoukankan      html  css  js  c++  java
  • 模糊查询

    #import <Foundation/Foundation.h>

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

        @autoreleasepool {

            NSMutableArray *array = [NSMutableArray arrayWithObjects:@"3",@"2",@"5",nil];

            NSArray* reversedArray = [[array reverseObjectEnumerator] allObjects];//倒序

            for (id str in reversedArray) {

                NSLog(@"%@",str);

            }

        }

        return 0;

    }

    #import <Foundation/Foundation.h>

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

        @autoreleasepool {

            //查找名字里面包含“王”的姓

            NSArray *array = [[NSArray alloc]initWithObjects:@"小王",@"王力",@"李丽",@"方方", nil];

            

            NSString *match = @"*王*";

            //查找姓王的名字,王字必须为首字则修改NSString *match=@"王*";

            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF like %@", match];

            

            NSArray *results = [array filteredArrayUsingPredicate:predicate];

            for (id str in results) {

                NSLog(@"%@",str);

            }

        }

        return 0;

    }

  • 相关阅读:
    Python Kivy 安装问题解决
    cisco asa5510 配置
    对于yum中没有的源的解决办法-EPEL
    python安装scrapy小问题总结
    win10 清理winsxs文件夹
    centos(7.0) 上 crontab 计划任务
    CentOS — MySQL备份 Shell 脚本
    python 2,3版本自动识别导入
    segmenter.go
    segment.go
  • 原文地址:https://www.cnblogs.com/bobohahaha/p/5120738.html
Copyright © 2011-2022 走看看