NSLog(@"%o",i); 八進(jìn)制輸出變量i NSLog(@"%#o",i); 八進(jìn)制前加0 NSLog(@"%x",i); 十六進(jìn)制輸出變量i NSLog(@"%#x",i); 十六進(jìn)制前加0x(abcdef是小寫) NSLog(@"%#X,i"),(ABCDEF是大寫)
interface 中: -:表示是實(shí)例方法,+:表示是類方法(比如alloc函數(shù)就是類方法)
char *str = "hello"; NSLog(@"%@",str); 沒有錯(cuò)誤,但是沒有得到想要的結(jié)果 NSLog(@"%s",str);結(jié)果正確
@property int x; @synthesize x; // it means getter method x ,and setter method setX [myInstance x]; == myInstance.x; [myInstance setX:13]; == (myInstance.x = 13;)
兩個(gè)參數(shù) -(void) setA:(int) a setB:(int) b; 或者 -(void) set:(int) a:(int) b
Category: @interface Fraction:NSObject {} @interface Fraction (MathOps)
release dealloc兩個(gè)的區(qū)別就是,dealloc直接銷毀內(nèi)存,release是將reference count-1(如果對象沒有其他的引用時(shí),release 和 dealloc的作用是一樣的)
NSFileManager *fm = [[NSFileManager alloc] init]; NSString *fName = [@"~/testfile" stringByExpandingTildeInPath];//“~”需要擴(kuò)展才能夠使用 [fm fileExistsAtPath:fName];
|