免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 855 | 回复: 0
打印 上一主题 下一主题

学习programming in objective-c 2.0 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 01:19 |只看该作者 |倒序浏览
NSLog(@"%o",i);  八进制输出变量i
NSLog(@"%#o",i); 八进制前加0
NSLog(@"%x",i); 十六进制输出变量i
NSLog(@"%#x",i); 十六进制前加0x(abcdef是小写)
NSLog(@"%#X,i"),(ABCDEF是大写)

interface 中:
-:表示是实例方法,+:表示是类方法(比如alloc函数就是类方法)

char *str = "hello";
NSLog(@"%@",str); 没有错误,但是没有得到想要的结果
NSLog(@"%s",str);结果正确

@property int x;
@synthesize x;   // it means  getter method x   ,and setter method setX
[myInstance x]; == myInstance.x;
[myInstance setX:13];  == (myInstance.x = 13;)

两个参数
-(void) setA:(int) a setB:(int) b;  或者  -(void) set:(int) a:(int) b

Category:
@interface Fraction:NSObject
{}
@interface Fraction (MathOps)

release   dealloc两个的区别就是,dealloc直接销毁内存,release是将reference count-1(如果对象没有其他的引用时,release 和  dealloc的作用是一样的)

NSFileManager  *fm = [[NSFileManager alloc] init];
NSString *fName = [@"~/testfile" stringByExpandingTildeInPath];//“~”需要扩展才能够使用
[fm fileExistsAtPath:fName];

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP