object c ÄÚ´æ¹ÜÀí
¿´ÁËϹٷ½ÎĵµµÄ¹ØÓÚobject c µÄÄÚ´æ¹ÜÀí,×ܽáÏÂ:
ÔÚiphoneÖÐobject c ÖеÄÄÚ´æ¹ÜÀíÊÇͨ¹ý¼ÆÊýÆ÷À´¹ÜÀíµÄ,ÿ¸ö¶ÔÏóÄÚ²¿¶¼ÓÐÒ»¸ö¼ÆÊýÆ÷.н¨Ò»¸ö¶ÔÏó,»òÕßÕâ¸ö¶ÔÏ󱻯äËû¶ÔÏóÒýÓÃ,¶à»áʹ¼ÆÊýÆ÷¼Ó1.Retain Ôö¼Ó¼ÆÊýÆ÷Öµ release ¼õÉÙ¼ÆÊýÆ÷Öµ.µ±¼ÆÊýÆ÷Ϊ0ʱ¶ÔÏó¾Ídealloc×Ô¼º.
ÔÚobject cÖÐÄãÉú³ÉµÄÒ»¸ö¶ÔÏóÄÇôÄã¾ÍÓÐÔðÈÎÈ¥ÊÍ·ÅËü£¬ÄÚ´æ¹ÜÀíµÄÒ»°ã¹æÔò£º
You own any object you create by allocating memory for it or copying it.
Related methods: alloc, allocWithZone:, copy, copyWithZone:, mutableCopy, mutableCopyWithZone:
If you are not the creator of an object, but want to ensure it stays in memory for you to use, you can express an ownership interest in it.
Related method: retain
If you own an object, either by creating it or expressing an ownership interest, you are responsible for releasing it when you no longer need it.
Related methods: release, autorelease
Conversely, if you are not the creator of an object and have not expressed an ownership interest, you must not release it.
¿¼ÂÇÏÂÃæÕâ¸öÀý×Ó£º
Thingamajig *thingamajig = [[Thingamajig alloc] init];
NSArray *sprockets = [thingamajig sprockets];
[thingamajig release];
thingamajig ÐèÒªrelease£¬ÒòΪºÜÏÔÈ»ÕâÀïÎÒÃÇÊÇthingamajig µÄowner¡££¨µÚÒ»Ìõ¹æÔò£©
ÄÇôsprockets Ϊʲô²»ÐèÒªreleaseÄØ¡£
Ê×ÏÈÎÒÃDz»ÊÇ sprockets µÄ creater.£¨µÚÒ»Ìõ¹æÔò£©,ÎÒÃÇҲûÓÐexpressing an ownership interest£¬ÒòΪÎÒÃÇûÓÐ
retainËü£¬£¨µÚ¶þÌõ¹æÔò£© ËùÒÔÎÒÃDz»¸ºÔðreleaseËü¡£
¾ßÌåÀ´¿´ thingamajig µÄ sprockets·½·¨µÄʵÏÖ£º
(NSArray *)sprockets {
NSArray *array;
array = [[NSArray alloc] initWithObjects:mainSprocket,auxiliarySprocket, nil];
return [array autorelease];
}
¿É¼û·ÖÅäµÄÄÚ´æÔÚ·
Ïà¹ØÎĵµ£º
±¾ÎĵÄÄÚÈÝÊÇ Win32 API£¨ÌرðÊǽø³Ì¡¢Ï̺߳͹²ÏíÄÚ´æ·þÎñ£©µ½ POWER ÉÏ Linux µÄÓ³Éä¡£±¾ÎÄ¿ÉÒÔ°ïÖúÄúÈ·¶¨ÄÄÖÖÓ³Éä·þÎñ×îÊʺÏÄúµÄÐèÒª¡£×÷ÕßÏòÄúÏêϸ½éÉÜÁËËûÔÚÒÆÖ² Win32 C/C++ Ó¦ÓóÌÐòʱÓöµ½µÄ API Ó³Éä¡£
¸ÅÊö
Óкܶ෽ʽ¿ÉÒÔ½« Win32 C/C++ Ó¦ÓóÌÐòÒÆÖ²ºÍÇ¨ÒÆµ½ pSeries ƽ̨¡£Äú¿ÉÒÔʹÓÃÃâ·ÑÈí¼þ»òÕßµÚÈý·½¹¤¾ßÀ´ ......
c±ä³ÉµÄ¶ÔÏó´ó¶àÊǹ²ÏíÄÚ´æÖÐÉêÇ룬±È½ÏÉÙÓÃmallocÖ±½ÓÀ´ÉêÇ룬ËùÒÔÁ´±íÉè¼ÆÒ»°ãÊÇÏÂÃæ2Öнṹ£º
¶ÔÏó --> ¶ÔÏó --> ¶ÔÏó
¶ÔÏó -->Á´±í¶ÔÏó-->¶ÔÏó -->Á´±í¶ÔÏó
£¨1£©¶ÔÓÚµÚÒ»ÖÖ£¬Á´±íÖ±½Ó¹ØÁªµ½¶ÔÏó±¾Éí£¬ËùÒÔÈç¹ûÒ»¸ö¶ÔÏóÔÚÏûÍöʱ£¬Ã»Óм°Ê±ÇåÀíµôÁ´±í¹ØÏµ£¬Ôò»áµ¼ÖÂÁ´±íµôÁ´¡£
£¨2£©Á´±í¶ÔÏó±¾ÉíÊÇÒ» ......
ÎÒÃǶ¼ÖªµÀgccµÄ-S¿ª¹Ø¿ÉÒÔÓÃÀ´Éú³É»ã±à´úÂ룬
µ«ÓÐʱºò£¬µ¥Óлã±àÎļþÊDz»¹»µÄ£¬ÎÒÃÇÏ£ÍûµÄÊǽ«CÓïÑÔ³ÌÐòµÄÔ´´úÂëºÍ»ã±àÓïÑÔÎı¾½»´íÔÚÒ»Æð²é¿´£¬
ÕâÊÇLISTING¹¦ÄÜ£¬ÔÚgccÖв¢Ã»ÓÐרÃŵÄFAQ˵Ã÷£¬
ÇøÇøÔÚÍøÉϲéÁ˺ܶà×ÊÁϲÅÖªµÀÔõôʵÏÖ£¬ËùÒÔÌØ´Ë¼ÇÏ¡£
gcc -c -g -Wa,-adlhn ee.c > ee.anno.s
ÓÉ´ËÉú³ÉµÄe ......
ºê
È«´óд, Èç¹û±ØÒª, ÓÃÁ¬×Ö·ûÁ¬½Óµ¥´Ê
#define SIZE_LIMIT 1024
#define CONFIG_DEBUG 1
#define PRODUCT_ID 0x1123
ö¾Ù
µ¥´ÊÊ××Öĸ´óд, ²»ÓÃÁ¬×Ö·û
enum {
KeyNumLock,
KeyShift,
Key1,
KayA
} Key;
......
int main()
{
printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60);
}
gcc -S±àÒë³É»ã±à´úÂëÈçÏÂ:
.file "test.c"
.section .rodata
.LC0:
&nbs ......