标签:style http ar sp for on log bs ef
//将“?文艺?青年”改成“213?青年”。
NSString *str = @"文艺青年";
NSString *str1 = [str stringByReplacingOccurrencesOfString:@"文艺" withString:@"213"];
NSLog(@"%@",str1);
//将 整数123 转换为字符串“123”。
NSString *s = [NSString stringWithFormat:@"%d",123];
NSLog(@"%@",s);
//将 “i love you”单词?首字?母变?大写 “I love You”
NSString *str2 = @"i love you";
NSLog(@"%@",[str2 capitalizedString]);
//截取字符串“20|http://www.baidu.com”中 “|” 前?面和后?面的字符串, 并输出。提?示:-componentsSeparatedByString:
NSString *st = @"20|http://www.baidu.com";
NSArray *arr = [st componentsSeparatedByString:@"|"];
NSLog(@"第一部分:%@",arr[0]);
NSLog(@"第二部分:%@",arr[1]);
//往可变数组?里存储 int、float、double、BOOL、NSRange等类型数
//据 遍历数组
NSNumber *n1 = [NSNumber numberWithInt:23];
NSNumber *n2 = [NSNumber numberWithFloat:1.2];
NSNumber *n3 = [NSNumber numberWithBool:YES];
NSValue *n4 = [NSValue valueWithRange:NSMakeRange(2, 2)];
NSMutableArray *muArray = [NSMutableArray arrayWithObjects:n1,n2,n3,n4, nil];
for (int i = 0; i < muArray.count; i++) {
NSLog(@"%@",muArray[i]);
}
标签:style http ar sp for on log bs ef
原文地址:http://www.cnblogs.com/iOS-mt/p/4108817.html