oc copy
来源:互联网 发布:完美假期周晨曦淘宝店 编辑:程序博客网 时间:2024/06/06 02:41
//// main.m// Copy//// Created by liyang on 15-6-12.// Copyright (c) 2015年 liyang. All rights reserved.//#import #import "Goodstudent.h"#import "student.h"#pragma mark 字符copy#pragma mark 字符copy (深拷贝)void stringcopy(){ NSString *str = [[NSString alloc]initWithFormat:@"age is %i",10]; NSMutableString *strMut = [str mutableCopy]; NSLog( @"%zi",[str retainCount]); NSLog(@"%zi",[strMut retainCount]); [strMut appendString:@"1234"]; NSLog(@"%@",str); NSLog(@"%@",strMut); NSLog( @"%i ",str == strMut); NSLog(@"%p",str); NSLog(@"%p",strMut); [strMut release]; [str release];}#pragma mark 字符copy (浅拷贝)void stringmutablecopy(){ NSString *str = [[NSString alloc]initWithFormat:@"age is %i",10]; NSLog( @"%zi",[str retainCount]); NSString *strMut = [str copy]; NSLog( @"%i ",str == strMut); NSLog(@"%zi",[strMut retainCount]); [strMut release]; [str release];}#pragma mark 字符copy (深拷贝)void mutablestringcopy(){ NSMutableString * strmuta =[ NSMutableString stringWithFormat:@"str is %i",20]; NSString *string = [ strmuta copy]; NSLog(@"%p",strmuta); NSLog(@"%p",string); [string release];}#pragma mark 字符copy (深拷贝)void mutablesTomustringcopy(){ NSMutableString * strmuta =[ NSMutableString stringWithFormat:@"str is %i",20]; NSMutableString *string = [ strmuta mutableCopy]; NSLog(@"%p",strmuta); NSLog(@"%p",string); [string release];}void studentcopy(){ student *stu = [[[student alloc]init ]autorelease]; NSMutableString * strmuta =[ NSMutableString stringWithFormat:@"str is %i",20]; stu.name = strmuta; [strmuta appendString:@"asasasddddd"]; NSLog(@"%@", strmuta); NSLog(@"%@",stu.name); }void studentNamecopy(){ /* student *stu = [student studentwithName:@"stu1"]; student *stugood = [stu copy]; NSLog(@"%@",stu); NSLog(@"%@",stugood); [stugood release];*/ Goodstudent *good = [Goodstudent goodstudentWithage:10 name:@"stugood"]; Goodstudent *stu2 = good; NSLog(@"%@", good); NSLog(@"%@",stu2);}int main(int argc, const char * argv[]){ @autoreleasepool { // stringcopy(); studentNamecopy(); } return 0;}
0 0
- oc copy
- OC语法之Copy
- 19-OC-copy语法
- 黑马程序员---oc copy
- OC中的copy
- OC中的copy
- OC的copy
- OC为什么需要copy
- iOS - OC Copy拷贝
- OC中的copy
- OC copy关键字
- OC 中 浅 copy 和 深 copy
- OC的深Copy和浅Copy
- 关于oc的retain copy
- OC自定义对象的copy
- 21-OC中的copy使用
- OC中copy的使用
- OC中copy的使用
- 方差分析的基本概念
- Linux ID
- ios程序猿学习Swift 第一天 从Hello World开始
- chapter12test4
- sicily 1687. Permutation
- oc copy
- 对于非阻塞socket的可写事件
- java分页数据导出excel
- 简单选择排序算法
- 滚动条+threshold()
- python 输出格式
- 如何制作GIF动态图片
- spring 定时任务
- 单链表的逆置-C++实现