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];
}
¿É¼û·ÖÅäµÄÄÚ´æÔÚ·
Ïà¹ØÎĵµ£º
VCÖÐÏÂÃæ¼¸¸ö½á¹¹Ìå´óС·Ö±ðÊǶàÉÙÄØ
struct MyStruct
{
double m4;
char m1;
int m3£»
};
struct MyStruct {
char m1;
double m4;
int m3;
};
#pragma pack(push)   ......
Ò»¡¢ º¯Êý²ÎÊý´«µÝ»úÖÆµÄ»ù±¾ÀíÂÛ ¡¡¡¡º¯Êý²ÎÊý´«µÝ»úÖÆÎÊÌâÔÚ±¾ÖÊÉÏÊǵ÷Óú¯Êý£¨¹ý³Ì£©ºÍ±»µ÷Óú¯Êý£¨¹ý³Ì£©ÔÚµ÷Ó÷¢Éúʱ½øÐÐͨÐŵķ½·¨ÎÊÌâ¡£»ù±¾µÄ²ÎÊý´«µÝ»úÖÆÓÐÁ½ÖÖ£ºÖµ´«µÝºÍÒýÓô«µÝ¡£ÒÔÏÂÌÖÂ۳Ƶ÷ÓÃÆäËûº¯ÊýµÄº¯ÊýΪÖ÷µ÷º¯Êý£¬±»µ÷Óõĺ¯ÊýΪ±»µ÷º¯Êý¡£¡¡¡¡Öµ´«µÝ£¨passl-by-value£©¹ý³ÌÖУ¬±»µ÷º¯ÊýµÄÐÎʽ²Î ......
ÍøÂí¼ÓÃÜÖУ¬Ä¿Ç°Óиöfunction(p,a,c,k,e,d)µÄ£¬·Ç³£ÌÖÑᣬÎÒÒ²ÊÇÉî¶ñÍ´¾ø£¬¼ÇµÃÎÒ¸Õ¿ªÊ¼Åöµ½ËüµÄʱºò£¬Æ´ÃüµØ¶Áº¯Êý£¬ÄǸö½ÐÍ´¿à°¡£¬¿Ä¿Ä°í°íµØÃãÇ¿¸ãÁ˳öÀ´¡£½ñÌ죬ͻȻ¿´¼ûÁËfunction(p,a,c,k,e,d)µÄ½âÃÜ´úÂ룬¸ßÐ˶¼À´²»¼°
<script>
a=62;
function encode() {
var code = document.getElementById('code' ......
ΪʲôÐèҪʹÓÃextern "C"ÄØ£¿C++Ö®¸¸ÔÚÉè¼ÆC++֮ʱ£¬¿¼Âǵ½µ±Ê±ÒѾ´æÔÚÁË´óÁ¿µÄC´úÂ룬ΪÁËÖ§³ÖÔÀ´µÄC´úÂëºÍÒѾдºÃC¿â£¬ÐèÒªÔÚC++Öо¡¿ÉÄܵÄÖ§³ÖC£¬¶øextern "C"¾ÍÊÇÆäÖеÄÒ»¸ö²ßÂÔ¡£
¡¡¡¡ÊÔÏëÕâÑùµÄÇé¿ö:Ò»¸ö¿âÎļþÒѾÓÃCдºÃÁ˶øÇÒÔËÐеúÜÁ¼ºÃ£¬Õâ¸öʱºòÎÒÃÇÐèҪʹÓÃÕâ¸ö¿âÎļþ£ ......
int main()
{
printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60);
}
gcc -S±àÒë³É»ã±à´úÂëÈçÏÂ:
.file "test.c"
.section .rodata
.LC0:
&nbs ......