写在前面的话
-
之前的同事问我字符串的问题 , 说字符串很简单 , 被我痛批 !我们的
UI
界面说破大天就是图片
+字符串
!!!我们花费多少的精力和时间在字符串的问题上都不为过! -
说到
UI
就不得不提到最近在学习也是在复习的React Native
, 上次学习的时候已经是去年的事儿了~回想一看还是有很多地方值得深究 , RN真正的操作点 , 应用点就是UI方面的设计! 就是因为UI可以应用RN所以他才有价值!!!
比较顺手的 Xcode快捷键
Tips
command + shift + O
快捷键可以快速打开系统或者自己想要查找的代码!
command + shift + J
可以迅速定位我当前的页面文件在左侧bundle栏的具体位置!
非常常用的快捷键分享给之前问我的同事和身边的小伙伴还有不知道的真应该 "鞭尸"
你们!!!哈哈哈
NSString.h
文件第18~28行 typedef NS_OPTIONS(NSUInteger, NSStringCompareOptions)
结构体代码
NSCaseInsensitiveSearch
代表大小写无关相等
typedef NS_OPTIONS(NSUInteger, NSStringCompareOptions) {
NSCaseInsensitiveSearch = 1,
/* Exact character-by-character equivalence */
NSLiteralSearch = 2,
/* Search from end of source string */
NSBackwardsSearch = 4,
/* Search is limited to start (or end, if NSBackwardsSearch) of source string */
NSAnchoredSearch = 8,
/* Added in 10.2; Numbers within strings are compared using numeric value, that is, Foo2.txt < Foo7.txt < Foo25.txt; only applies to compare methods, not find */
NSNumericSearch = 64,
NS_ENUM_AVAILABLE(10_5, 2_0) = 128,
/* If specified, ignores diacritics (o-umlaut == o) */
NSDiacriticInsensitiveSearch
NS_ENUM_AVAILABLE(10_5, 2_0) = 256,
/* If specified, ignores width differences ('a' == UFF41) */
NSWidthInsensitiveSearch
NS_ENUM_AVAILABLE(10_5, 2_0) = 512,
/* If specified, comparisons are forced to return either NSOrderedAscending or NSOrderedDescending if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with NSCaseInsensitiveSearch specified) */
NSForcedOrderingSearch
NS_ENUM_AVAILABLE(10_7, 3_2) = 1024
/* Applies to rangeOfString:..., stringByReplacingOccurrencesOfString:..., and replaceOccurrencesOfString:... methods only; the search string is treated as an ICU-compatible regular expression; if set, no other options can apply except NSCaseInsensitiveSearch and NSAnchoredSearch */
NSRegularExpressionSearch
}
示例代码
NSString *str1 = @"🍎" ;
NSString *str2 = @"🍌" ;
NSComparisonResult compareResult = [str1 compare:str2 options:NSCaseInsensitiveSearch] ;
BOOL result1 = compareResult == 0 ;
BOOL result2 = [str1 isEqualToString:str2] ;
NSLog(@"compare: %@ , isEqualToString:%@" , result1 ? @"YES" : @"NO" , result2 ? @"YES" : @"NO") ;
数组中放入一个空对象 -- NSNull的使用
//遍历数组中的元素 , 直到找到nil就停止 ,
//nil之前所遍历的元素就是该数组中的元素:
NSArray *array1 = [[NSArray alloc] initWithObjects:@1 , @2 , @3 , @4, nil] ;
//如果我直接放入一个nil到数组中势必会遍历不完全 ,
//如果我在@3位置放入nil , 那么就只会输出1, 2 这两个值 ,
//4就不会被输出了!所以这时候NSNull就有了用武之地了!
NSArray *array2 = [[NSArray alloc] initWithObjects:@1 , @2 , [NSNull null] , @4, nil] ;
NSLog(@"array1: %@ , array2: %@" , array1 , array2) ;
网友评论