本帖最后由 寇亮 于 2014-8-12 23:49 编辑
1. OC中字符串以@开头。 @”hello everyone” 2. OC字符串创建与输出: NSString *str = @”itcast”; NSString *newStr = [NSString stringWithFormat: @"My ageis %d and no is %d and name is %@", age, no, name]; NSLog(@”我在%@上课”,str); 注:NSLog输出C语言字符串的时候不能有中文! 3. 字符串length方法返回的是字符串的字数(空格算一个字): NSString *name = @”哈哈jack”; //size==6 int size = [name length];
|