Objective-C学习 笔记

数据类型:

NS是Cocoa类对象类型的前缀,定义为 NSxxxx * 实例名

@"字符串"; //@代表这个是NSString字符串,难道OC就没有普通字符串了吗?

NSString类型:

NSString *a = @"字符串!";  //这种定义,系统自动释放

NSString *a = [[NSString alloc] initWithFormat:@"字符串!"];//这种定义需要手动释放 [a release]

NSInteger和NSUInteger类型:

CGFloat类型:

 id, NSObject,init,float,double,char

 

(NSObject *)参数

修饰符 + 和 -,+为普通方法,-为静态方法

 

实例化

foo= [类 new]

 

方法

[类|静态类 方法 : 方法]

 

[Foo new] == [[Foo alloc] init] ??

 

资源管理

NSAutoreleasePool * pool = [NSAutoreleasePool new];//建立内存空间
context........
[pool drain];//释放内存

@autoreleasepool{
      context........
}


 

你可能感兴趣的:(cocoa,float)