NSString,NSMutableString

NSString

NOTE

An immutable string is a text string that is defined when it is created and subsequently cannot be changed. An immutable string is implemented as an array of Unicode characters (in other words, a text string). To create and manage an immutable string, use the NSString class. To construct and manage a string that can be changed after it has been created, use NSMutableString.

NSString 管理自符串的对象
内容:只读,不可改变

注意点:如果要继承NSString 必须重载characterAtIndex: 和length 这两个方法
编码方式:unicode,这个方法availableStringEncodings 可查看提供的编码,当我门从其他类型的字符串转换的时候可以指定编码。

NString 自符串 常量 和C语言一样 他们在编译的时候,会在一个常量区里,直到程序运行完毕后才被释放。

NSMutableString

他是NSString子类,只一个一个可变的区域

编程中容易犯的错误
当函数返回类型是NSString 时 ,函数返回的是NSMutableString,这样是没有错的,但是接受返回值的变量指向却是NSMutableString,一不小心改变了,变量也会跟着变,这时我们需要copy 一下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值