OC3_Copy及MultableCopy
//
// main.m
// OC3_Copy及MultableCopy
//
// Created by zhangxueming on 15/6/19.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h>
//copy mutableCopy
int main(int argc, const char * argv[]) {
@autoreleasepool {
//copy 把可变对象及不可变对象 copy生成不可变对象
NSString *str = @"hello world";
NSString *str1 = [str copy];
//[str1 insertString:@"qianfeng" atIndex:4];
NSLog(@"str = %p str1 = %p", str, str1);
NSLog(@"str1 = %@", str1); NSMutableString *str2 = [NSMutableString stringWithString:@"hello world"];
NSString *str3 = [str2 copy];
//[str3 insertString:@"qianfeng" atIndex:4];
NSLog(@"str3 = %@", str3); //mutableCopy 把可变或者不可变对象copy生成可变对象 NSString *str4 = @"qianfeng";
NSMutableString *str5 = [str4 mutableCopy];
[str5 insertString:@"hello" atIndex:];
NSLog(@"str5 = %@", str5); NSMutableString *str6 = [NSMutableString stringWithString:@"qianfeng"];
NSMutableString *str7 = [str6 mutableCopy];
[str7 insertString:@"world" atIndex:];
NSLog(@"str7 = %@", str7); }
return ;
}
OC3_Copy及MultableCopy的更多相关文章
- iOS copy 和 mutableCopy 学习
(参考 iOS 52个技巧学习心得笔记 第二章 对象 , 消息, 运行期)的对象部分 关于Copy 有个经典问题”大部分的时候NSString的属性都是copy,那copy与strong的情况下到底 ...
- iOS 52个技巧学习心得笔记 第二章 对象 , 消息, 运行期
1. 属性 在开发过程中经常要用到定义属性,@property和@synthesize是经常用到的属性, property在.h文件中作声明,@synthesize在.m文件中用于实现 // Stud ...
随机推荐
- Excel设置数据有效性实现单元格下拉菜单的3种方法(转)
http://blog.csdn.net/cdefu/article/details/4129136 一.直接输入: 1.选择要设置的单元格,譬如A1单元格: 2.选择菜单栏的“数据”→“有效性”→出 ...
- Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树
C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...
- 算法:排序----Java选择排序
public static void selectionSort(int[] arr) { int len = arr.length; for (int i = 0; i < len; i++) ...
- 返回ListBox选中的多项目
//返回ListBox选中的多项目 procedure TForm1.Button2Click(Sender: TObject);vari:Integer;s:string;begin for i ...
- ios开发——实用技术篇&XML协议详解
XML的数据协议组成 名词 说明 md5 message-digest algorithm 5 http hypertext transfer protocol xml extensible mark ...
- linux后端运行(二)
在用管理员执行一个命令后,用Ctrl+Z把命令转移到了后台.导致无法退出root的. 输入命令:exit终端显示:There are stopped jobs. 解决方法:方法一.输入命令:jobs终 ...
- POJ 2498 Martian Mining
Martian Mining Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2194 Accepted: 1326 De ...
- js页面刷新的几种方法
Javascript刷新页面的几种方法: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(locat ...
- [改善Java代码]三元操作符的类型务必一致
建议三: 三元操作符是if-else的简化写法,在项目中使用它的地方很多,也非常好用,但是好用又简单的东西并不表示就可以随便用,我们来看看下面这段代码: public class Client { p ...
- Mirco2440核心板设计思考
1.核心板架构 注意的是:此处的RAM和ROM都是外置的 硬件框架 S3C2440+ SDRAM + NAND Flash + NOR Flash 也就是 CPU + RAM + ROM 2.S3C2 ...