數據類型:
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........
}