PJR-NSString-CategoryNSString 的分类
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"); }
评论
RNTextStatisticsNSString 的分类
RNTextStatistics 项目是 Dave Child 的 Text-Statistics
RNTextStatisticsNSString 的分类
0
MVBouncyViewUIView 的分类
MVBouncyView是UIView的分类,提供圆角控制效果。UIView*view=(someviewinyourcode)view.bounceAmplitude=1.25f;//optiona
MVBouncyViewUIView 的分类
0
RNTextStatisticsNSString 的分类
RNTextStatistics项目是DaveChild的Text-Statistics项目的Objective-C移植版本。这是NSString的分类,实现对单词和句子的统计。示例代码:NSStri
RNTextStatisticsNSString 的分类
0
UIView+EasingFunctionsUIView 的分类
UIView+EasingFunctions 是 UIView 的分类,允许用户轻松实现阴影、自定义
UIView+EasingFunctionsUIView 的分类
0
NSString+ColorNSString 的分类
NSString+Color 是 NSString 的分类,可实现简单的色彩初始化,支持 Web 色
NSString+ColorNSString 的分类
0
UIView+EasingFunctionsUIView 的分类
UIView+EasingFunctions是UIView的分类,允许用户轻松实现阴影、自定义圆角、alpha、颜色和方向。
UIView+EasingFunctionsUIView 的分类
0
NSString+ColorNSString 的分类
NSString+Color是NSString的分类,可实现简单的色彩初始化,支持Web色彩和自定义颜色。示例: [@"red" representedColor]; [@"redColor" rep
NSString+ColorNSString 的分类
0