标题: Foundation框架之不可变字符串 [打印本页] 作者: mac 时间: 2015-9-23 10:09 标题: Foundation框架之不可变字符串 //
// main.m
// FoundationFramework
//
// Created by Kenshin Cui on 14-2-16.
// Copyright (c) 2014年 Kenshin Cui. All rights reserved.
//
//以上方法都有对应静态方法(一般以string开头),不需要管理内存(系统静态方法一般都是自动释放)
NSString *str7=[NSString stringWithString:@"Objective-C string"];
}
void test2(){
NSLog(@"\"Hello world!\" to upper is %@",[@"Hello world!" uppercaseString]);
//结果:"Hello world!" to upper is HELLO WORLD!
NSLog(@"\"Hello world!\" to lowwer is %@",[@"Hello world!" lowercaseString]);
//结果:"Hello world!" to lowwer is hello world!
//首字母大写,其他字母小写
NSLog(@"\"Hello world!\" to capitalize is %@",[@"Hello world!" capitalizedString]);
//结果:"Hello world!" to capitalize is Hello World!