//字符串//NSString类实例方法NSLog(@"输入的网址为:%@",str);//查值int str_len = [str length];//求其长度NSLog(@"长度为:%d字节",str_len);char c = [str characterAtIndex:11];//找字符NSLog(@"%c",c);//[str description]//字符串(格式化)拼接NSMutableString * str_ = [[NSMutableString alloc] initWithFormat:@"+++iphone IOS"];NSLog(@"%@",[str stringByAppendingFormat:@"%@",str_]);//求子串NSLog(@"%@",[str substringFromIndex:11]);//求后串。求第11个字符以及之后的字符串,包括第11个字符。NSLog(@"%@",[str substringToIndex:11]);//求前串。求第11个字符之前的字符串,不包括第11个字符。//字符串转换为基本类型// -(double) doubleValue -(int) intValue -(float) floatValue -(BOOL) boolValueNSLog(@"%f,%d,%f,%d",[str doubleValue],[str intValue],[str floatValue],[str boolValue]);//单词首字母大写,全小写,全大写//– capitalizedString – lowercaseString – uppercaseStringNSLog(@"%@,%@,%@",[str_ capitalizedString],[str_ lowercaseString],[str_ uppercaseString]);//比较字符串是否相等NSLog(@"%d",[str isEqualToString:str_]);//比较字符串大小//-(NSComparisonResult)compare:(NSString *) str// compare方法会返回三种NSComparisonResult类型的值// NSOrderedAscending = -1 //递增,升序// NSOrderedSame = 0 //相同// NSOrderedDescending = 1 //递减//例子:NSMutableString * tr1 = [[NSMutableString alloc] initWithFormat:@"1"];NSMutableString * tr2 = [[NSMutableString alloc] initWithFormat:@"2"];NSLog(@"%d",[tr1 compare:tr2]);