Coder Social home page Coder Social logo

ffchinesesort's Introduction

FFChineseSort

中文数组排序分类 & 汉字转拼音分类

语言

  • Objective-C

安装

CocoaPods

在终端输入以下命令安装 cocoapods

$ gem install cocoapods
  • Podfile 中添加以下内容
pod 'FFChineseSort'
  • 如果还没有 Podfile,可以直接输入以下命令:
$ echo "pod 'FFChineseSort'" > Podfile
  • 在终端之行以下命令安装 Pod
$ pod install

使用

排序数组

  • 导入头文件
#import <NSArray+Chinese.h>
  • 排序字符串数组
NSArray *strings = @[@"张三", @"李四", @"王五", @"赵六", @"安娜"];

NSArray *result = [strings sortedWithChineseKey:nil];
  • 排序字典数组
NSMutableArray *arrayM = [NSMutableArray array];
NSDictionary *dict1 = @{@"name": @"张三", @"title": @"经理", @"age": @20, @"height": @1.7};
[arrayM addObject:dict1];
NSDictionary *dict2 = @{@"name": @"李四", @"title": @"老板", @"age": @18, @"height": @1.6};
[arrayM addObject:dict2];

NSArray *result = [arrayM sortedWithChineseKey:@"name"];
  • 排序对象数组
Person *p = [Person personWithDict:@{@"name": @"张三", @"title": @"经理", @"age": @20, @"height": @1.7}];
[persons addObject:p];
p = [Person personWithDict:@{@"name": @"李四", @"title": @"老板", @"age": @18, @"height": @1.6}];
[persons addObject:p];

// 按照 name 排序
NSArray *result1 = [persons sortedWithChineseKey:@"name"];

// 按照 title 排序
NSArray *result2 = [persons sortedWithChineseKey:@"title"];

中文转拼音

  • 导入头文件
#import <NSString+Chinese.h>
  • 生成拼音字符串
NSLog(@"%@", @"张三".pinyinString);
NSLog(@"%@", @"重庆".pinyinString);
NSLog(@"%@", @"重量".pinyinString);
NSLog(@"%@", @"".pinyinString);
NSLog(@"%@", @"123456张三654abc".pinyinString);
NSLog(@"%@", @"😄张三😄".pinyinString);

ffchinesesort's People

Contributors

liufan321 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.