NSString*compare2 =@"2";//- (NSComparisonResult)compare:(NSString *)string; 比较方法返回值是NSComparisonResult,他是一个枚举类型//typedef NS_ENUM(NSInteger, NSComparisonResult) {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending};if([compare1 compare:compare2] ==NSOrderedAscending ){ NSLog(@...
typedefNS_ENUM(NSInteger,TestType){TestTypeA=0,TestTypeB,TestTypeC}; 原有转换方法: +(NSString*)getTestTypeString:(TestType)t{NSString*result=nil;switch(t){caseTestTypeA:result=@"TypeA";break;caseTestTypeB:result=@"TypeB";break;caseTestTypeC:result=@"TypeC";break;default:result=@"u...
NSString篇: 1.字符串连接 1NSString *beijing =@"北京";2NSString *welcome = [beijing stringByAppendingString:@"欢迎你"];//字符串连接3NSLog(@"%@",welcome); //两种效果相同的字符串连接NSString *str22 = [str20 stringByAppendingFormat:@"%@",str21]; NSString*str23 = [str20 stringByApp...
NSString *string01 = @"hello world"; NSString *string02 = @"hello world"; BOOL result = [string01 caseInsensitiveCompare:string02] = = NSOrderedSame; enum _NSComparisonResult { NSOrderedAscending = -1, // string01 小于 string02 NSOrderedSame, string01 等于 string02 NSOrderedDescending string01 ...
NSArray*arr=[NSArray arrayWithObjects:@"bei",@"jing",@"huan",@"ying",@"nin",nil];NSDictionary*dic=[NSDictionary dictionaryWithObjectsAndKeys:@"value1",@"key1",@"value2",@"key2",nil];// 创建数组 正序 迭代器NSEnumerator*arrEnumer1=[arr objectEnumerator];// 创建数组 反序 迭代器NS...
常见的NSString和NSMutableString方法: [plain]view plaincopy +(id) stringWithContentsOfFile:path encoding:enc error:err 创建一个新字符串并将其设置为path指定的文件的内容,使用字符编码enc,如果非零,则返回err中错误 +(id) stringWithContentsOfURL:url encoding:enc error:err ...
typedef enum { aa=100, bb, cc , }TagSystemViews ; 常量的声明3 静态常量声明:static NSString *lc=@"test"; 预处理宏 预处理宏声明: #define network 1 #define NSLog() 3).#import包含头文件 4)#pragram mark分隔代码块 #pragram mark - ...
iOS typedef NS_ENUM 与 NSString //在头文件中声明typedef NS_ENUM(NSUInteger, TransactionState) { TransactionOpened, TransactionPending, TransactionClosed, };externNSString * NSStringFromTransactionState(TransactionState state); //在.m文件中实现NSString*NSStringFromTransactionState(TransactionState state)...
.h 一、创建枚举 二、类方法 1、NSDate转时间戳 2、NSDate转String 3、String转时间戳 4、获取单个时间 5、其他方法 .m
- (BOOL)hasPrefix:(NSString *)string; - (int)intValue; - (double)doubleValue; - (NSString *)stringByAppendingString:(NSString *)string; // 给一个字符串附加一个字符串string。 - (NSString *)stringByAppendingFormat:(NSString *)string; ...