标签:
NSString * str = @"adf";
NSString * str3 = [NSString stringWithFormat:@"%@,%@",@"a",@"b"];
char * c = "www";
NSString * str4 = [[NSString alloc] initWithCString:c encoding:nil];
NSUInteger length = [str length];
unichar c = [str2 characterAtIndex:2];//索引值是从 0 开始的
NSString * tmpStr = [str3 substringFromIndex:3];
NSString * tmpStr2 = [str3 substringToIndex:3];
NSString * tmpStr3 = [str3 substringWithRange:rang];
NSRange tmpRange = [str3 rangeOfString:tmpStr4];
if (str == nil || str.length == 0)
{
NSLog(@"字符串为空");
}
BOOL isPerfix = [str2 hasPrefix:@"xww"];
BOOL isSuffix = [str3 hasSuffix:@".txt"];
BOOL isEqual = [pstr5 isEqualToString:pstr3];
NSComparisonResult result = [strTmp1 compare:strTmp2];
NSString * str1 = [NSString stringWithFormat:@"%d",a];
NSString * str3 = [NSString stringWithFormat:@"%.1f",f];
NSString * str4 = [NSString stringWithFormat:@"%.4f",d];
NSString * str5 = [NSString stringWithFormat:@"%c",c];
int i1 = [str6 intValue];
float f1 = [str7 floatValue];
double d1 = [str8 doubleValue];
//7.将字符串中的字母转换成大写
NSString * str10 = @"china";
NSString * tmpStr1 = [str10 uppercaseString];
NSLog(@"tmpStr1 %@ str10 %@",tmpStr1,str10);
//8.将字符中的字母转换成小写
NSString * str11 = @"CHINA";
NSString * tmpStr2 = [str11 lowercaseString];
NSLog(@"tmpStr2 %@",tmpStr2);
//9.将首字母大写
NSString * str12 = @"china";
NSString * tmpStr3 = [str12 capitalizedString];
NSLog(@"tmpStr3 %@",tmpStr3);
NSString * date = [NSString stringWithFormat:@"%d年%d月%d日",year,month,day];
NSString * str2 = [str1 stringByAppendingString:@"itcast.cn"];
NSString * str4 = [str3 stringByReplacingCharactersInRange:range withString:@"itcast."];
NSString * str6 = [str5 stringByReplacingOccurrencesOfString:@"w" withString:@"a"];
BOOL isWriteSuccess = [content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];
NSString * str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
NSMutableString * muStr = [[NSMutableString alloc] initWithCapacity:0];
//是初始化字符串内容
[muStr setString:@"www"];
NSLog(@"mustr %p",muStr);
//动态的给字符串末尾追加新值
[muStr appendString:@".cn"];
//在指定的索引位置,插入字符串
[muStr insertString:@".itcast" atIndex:3];
//删除指定范围的字符串
//你要删除的长度,一定不能够超出字符串的的长度,导致异常Range or index out of bounds
NSRange range = {3,7};
// [muStr deleteCharactersInRange:range];
[muStr replaceCharactersInRange:range withString:@"传智播客"];
//1.创建一个NSRange结构体 表示范围
NSRange range = {4,5};
NSRange range2 = NSMakeRange(4, 5);
NSString * strRange = NSStringFromRange(range);
NSLog(@"strRange %@",strRange);
//2.NSSize 等同于 CGSize 有两个值组成 weight表示宽度 height高度
NSSize size = {21,19};
NSSize size2 = NSMakeSize(21, 19);
NSString *strSize = NSStringFromSize(size2);
NSLog(@"strSize %@",strSize);
//3.NSPoint 等同CGPoint 表示一个点的坐标位置
NSPoint point = {20,40};
NSPoint point2 = NSMakePoint(20, 40);
NSString * strPoint = NSStringFromPoint(point);
NSLog(@"strPoint %@",strPoint);
//4.NSRect
NSRect rect = {40,60,100,200};
NSRect rect2 = NSMakeRect(0, 10, 100, 100);
NSString * strRect = NSStringFromRect(rect);
NSLog(@"strRect %@",strRect);
#pragma mark 判断数组中是否存在某个对象
BOOL isContain = [array containsObject:p1];
标签:
原文地址:http://www.cnblogs.com/vtsay/p/4619748.html