PJR-NSString-Category

码农软件 · 软件分类 · 其他(Others) · 2019-07-24 10:28:59

软件介绍

 PJR-NSString-Category 是 NSString 的分类,可以执行很多字符串操作,包括:

  • String validation.

  • Email validation.

  • Phone validation.

  • URL validation.

  • Add or remove substring.

  • Get Substring.

  • Get Application version.

  • Get Application Name.

  • Generate Array from string.

  • Get String from Array.

  • Get Number of words in String.

  • Check if my string contains only letters, only numbers or both.

  • Convert NSData from NSString.

示例代码:

//Examples of NSString Category

NSString *testStr = @"Hello";

if([testStr isValid]){
    NSLog(@"It is a Valid String");
}

NSString *blankStr = @"  ";
if([blankStr isBlank]){
    NSLog(@"It is a blank String");
}

NSString *noOfWordsStr = @"Number of Words";
NSLog(@"Number of words are :%d",[noOfWordsStr countNumberOfWords]);

if([noOfWordsStr containsString:@"of"]){
    NSLog(@"YES");
}

if([noOfWordsStr isBeginsWith:@"N"]){
    NSLog(@"YES");
}

if([noOfWordsStr isEndssWith:@"s"]){
    NSLog(@"YES");
}

NSLog(@"string after replace charcter is :%@",[noOfWordsStr replaceCharcter:@"of" withCharcter:@"offfff"]);

NSLog(@"Get substring :%@",[noOfWordsStr getSubstringFrom:1 to:6]);

NSLog(@"Add string :%@",[noOfWordsStr addString:@" are 3"]);

NSLog(@"Removed string :%@",[noOfWordsStr removeSubString:@"of"]);

NSString *letterStr = @"abcd";
NSString *numberStr = @"1234";
NSString *letterNuberStr = @"sdf545";

if([letterStr containsOnlyLetters]){
    NSLog(@"Contanis only letters");
}

if([numberStr containsOnlyNumbers]){
    NSLog(@"Contanis only numbers");
}

if([letterNuberStr containsOnlyNumbersAndLetters]){
    NSLog(@"Contanis letters and numbers");
}

NSArray *array = [NSArray arrayWithObjects:letterStr,numberStr,letterNuberStr, nil];
if([numberStr isInThisarray:array]){
    NSLog(@"Yes number string is in this array");
}

NSLog(@"String from array is :%@",[NSString getStringFromArray:array]);

NSLog(@"Array from String is :%@",[noOfWordsStr getArray]);

NSLog(@"My Application Version number is :%@",[NSString getMyApplicationVersion]);

NSLog(@"My Application name is :%@",[NSString getMyApplicationName]);

if([@"pjr@gmail.com" isValidEmail]){
    NSLog(@"It is valid Email");
}
if(![@"21323gf" isVAlidPhoneNumber]){
    NSLog(@"It is not valid Phone number");
}
if([@"http://www.google.com" isValidUrl]){
    NSLog(@"It is valid URL");
}

本文地址:https://codercto.com/soft/d/10822.html

未来简史

未来简史

[以色列] 尤瓦尔·赫拉利 / 林俊宏 / 中信出版集团 / 2017-2 / 68.00元

进入21世纪后,曾经长期威胁人类生存、发展的瘟疫、饥荒和战争已经被攻克,智人面临着新的待办议题:永生不老、幸福快乐和成为具有“神性”的人类。在解决这些新问题的过程中,科学技术的发展将颠覆我们很多当下认为无需佐证的“常识”,比如人文主义所推崇的自由意志将面临严峻挑战,机器将会代替人类做出更明智的选择。 更重要的,当以大数据、人工智能为代表的科学技术发展的日益成熟,人类将面临着从进化到智人以来z......一起来看看 《未来简史》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具