- #import <Foundation/Foundation.h>
- int main(int argc, const char * argv[]) {
- @autoreleasepool {
-
- //创建可变字符串
- NSMutableString *str=[NSMutableString string];
-
- NSMutableString *str1=[NSMutableString stringWithFormat:@"asdasd"];
-
- [str1 appendFormat:@"123"];
-
- NSString *str3=@"000000";
- [str1 appendString:str3];
- [str1 appendString:@"2222"];
- NSLog(@"str1=%@",str1);
-
-
- NSString *str5=@"hello";
- //此时options:<#(NSStringCompareOptions)#> 括号内可以设置为0 0表示参数不起作用 因为是位枚举 才可以这么用
- NSRange range= [str5 rangeOfString:@"o" options:0 range:NSMakeRange(0, 5)];
-
- if (range.location!=NSNotFound) {
-
- NSLog(@"%lu%\n%lu",
-
- range.location,range.length);
- }else
- {
-
- NSLog(@"no");
-
- }
- }
- return 0;
- }
复制代码
|
|