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

3D打印

3D打印

[美]胡迪•利普森,梅尔芭•库曼 / 赛迪研究院专家组 / 中信出版社 / 2013-4 / 49.00元

《3D打印:从想象到现实》内容简介:你需要一把功能强大的锤子?你需要一双精致无比的鞋子?你需要给孩子准备奇异的玩具?你需要一顿精美的晚餐?只管打印出来就行了。《3D打印:从想象到现实》带你走进3D打印的世界,认识一下当下这个最酷的东西——它将从想象变成现实,并带来一场深刻的社会革命。 书中讲述了3D打印技术的突破性发展,以及3D打印技术将如何应用在学校、厨房、医院等场所的。《3D打印:从想象......一起来看看 《3D打印》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

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

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换