等價(jià)于:
NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc] init]; NSString *str = [[[NSString alloc] initWithString: @”str”] autorelease]; //給對(duì)象發(fā)送autorelease的信息,當(dāng)NSAutoreleasePool結(jié)束時(shí),標(biāo)記過“autorelease”的對(duì)象會(huì)被釋放,而ARC可自動(dòng)發(fā)送autoreleasepool。 [pool release]; //str is released
??適合于循環(huán)中的臨時(shí)變量,每次循環(huán)都會(huì)被釋放。(#?難道不會(huì)耗費(fèi)時(shí)間嗎?#)
每個(gè)框架都有一個(gè)主頭文件,包含各個(gè)頭文件。例如 < Foundation/Foundation.h >
??Cocoa的函數(shù)將使用NS前綴
typedef struct { int a , b , c; } St; //賦值 St t1 = { 1,2,3 };
for (NSString *str in array) { NSLog(@”%@”,str); }
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注