Objective C 2.0 ÊôÐÔ(Property)
ÔÌûÒ»£ºhttp://blog.csdn.net/dotphoenix/archive/2009/05/20/4203075.aspx
ÔÌù¶þ£ºhttp://www.cocoachina.com/bbs/read.php?tid-8008.html
@property (²ÎÊý) ÀàÐÍ Ãû×Ö;
ÕâÀïµÄ²ÎÊýÖ÷Òª·ÖΪÈýÀࣺ¶ÁдÊôÐÔ£¨readwrite/readonly£©£¬setterÓïÒ⣨assign/retain/copy£©ÒÔ¼°atomicity£¨nonatomic£©¡£
assign/retain/copy¾ö¶¨ÁËÒÔºÎÖÖ·½Ê½¶ÔÊý¾Ý³ÉÔ±¸³ÓèÐÂÖµ¡£ÎÒÃÇÔÚÉùÃ÷summary properyʱʹÓÃÁËreadonly£¬ËµÃ÷¿Í»§¶ËÖ»ÄܶԸÃproperty½øÐжÁÈ¡¡£atomicityµÄĬÈÏÖµÊÇatomic£¬¶ÁÈ¡º¯ÊýΪÔ×Ó²Ù×÷¡£
ÔÚobjective c 2.0Ï£¬ÓÉÓÚÎÒÃÇÉùÃ÷ÁËproperty£¬implementationÎļþ¿ÉÒÔ¸ü¸ÄÈçÏ£º
¿ÉÒÔ¿´µ½Êý¾Ý³ÉÔ±titleºÍnumofpagesµÄ¶Áдº¯ÊýÒѾ²»¸´´æÔÚ£¬È¡¶ø´úÖ®µÄÊÇÁ½ÐÐ@synthesize£¬
¼ûÏÂÁÐʾÀý´úÂ룺
//test.h
@interface MyTest : NSObject {
int myArray[5];
}
@end
Èç¹û²ÉÓÃ
@property int myArray[5];
¿Ï¶¨»á³ö´í¡£
ÒòΪ@propertyµÄÉùÃ÷ָʾ±àÒëÆ÷ĬÈϵظømyArrayÌí¼ÓÁËmyArrayÒÔ¼°setMyArrayµÄÕâÑùÒ»¶ÔgetterºÍsetter·½·¨¡£ÓÉÓÚobjective-CÖз½·¨µÄ·µ»ØÀàÐͲ»ÄÜÊÇÊý×飬ËùÒÔÉÏÊöÉùÃ÷propertyµÄ·½Ê½ÊÇͨ²»¹ý±àÒëµÄ¡£
ÕýÈ·µÄ·½Ê½ÊÇ£º
//test.h
@interface MyTest : NSObject {
int myArray[5];
}
- (void)outPutValues;
@property int* myArray;
@end
¼´£¬Ê¹ÓÃÖ¸ÕëÀ´±íʾ·µ»ØÀàÐͲ¢×÷Ϊ²ÎÊýÉèÖÃÀàÐÍ¡£
²»¹ýÕâÑùÒ»À´¾ÍÎÞ·¨ÔÚ.mÎļþµÄʵÏÖÖÐʹÓÃ@synthesize£¬¶øÊÇÐèÒªÏÔʽµØʵÏÖÕâ¶Ô·½·¨£º
#import <Foundation/Foundation.h>
#import "test.h"
#include <stdio.h>
@implementation MyTest
- (int*)myArray
{
return myArray;
}
- (void)setMyArray:(int*)anArray
{
if(anArray != NULL)
{
for(int i=0; i<5; i++)
myArray[i] = anArray[i];
}
}
ÕâÑùÒ»À´¶ÔÓÚÊý×éÐͱäÁ¿³ÉÔ±¾ÍÎÞ·¨Ê¹Óõ㣨.£©²Ù×÷·ûÀ´³éÏóµô¶ÔsetterºÍgetterµÄµ÷Óã¨Ê¹Óõã²Ù×÷·û·ÃÎʶÔÏóµÄ³ÉÔ±Êý¾Ý·Ç³£·½±ã£¬
¸ù¾ÝË÷Òª·ÃÎʵÄÊý¾Ý³ÉÔ±´¦ÓÚ×óÖµ»¹ÊÇÓÒÖµ¶øÓɱàÒëÆ÷×Ô¶¯Åж¨µ÷ÓÃsetter»¹ÊÇgetter£©¡£
Ïà¹ØÎĵµ£º
ÁËCÈ»ºóC++£¬È»ºóMFC/Windows,È»ºóÊÇC#,ÆäÖÐÊý¾ÝÀàÐͺܶ࣬ÓÉ»ù±¾ÀàÐÍÑÜÉúµÄtypedefÀàÐÍÒ²N¶à¡£ÊìÖª»ù±¾Êý¾ÝÀàÐÍÊÇÎÒÃÇÕýÈ·±í´ïʵ¼ÊÎÊÌâÖи÷ÖÖÊý¾ÝµÄÇ°ÌᣬÒò´ËÎÒ·ÖÀà×ܽáÁËÒ»ÏÂC/C++/Windows /C#»ù±¾Êý¾ÝÀàÐÍ£¬ÒÔ±ãÈÕºó²éÔÄ¡£
ANSI C/C++»ù±¾Êý¾ÝÀàÐÍ£º
Type
Size
Ê ......
B/S½á¹¹£¨Browser/Server½á¹¹£©½á¹¹¼´ä¯ÀÀÆ÷ºÍ·þÎñÆ÷½á¹¹¡£
1.½ÚÔ¼³É±¾~~~~~
´ó´ó¼ò»¯ÁË¿Í»§¶ËµçÄÔÔغɣ¬¼õÇáÁËϵͳά»¤ÓëÉý¼¶µÄ³É±¾ºÍ¹¤×÷Á¿£¬½µµÍÁËÓû§µÄ×ÜÌå³É±¾£¨TCO)!ËüÊÇÒ»´ÎÐÔµ½Î»µÄ¿ª·¢!
2.°²È«~~~
ËüÄÜÓÐЧµØ±£»¤Êý¾Ýƽ̨ºÍ¹ÜÀí·ÃÎÊȨÏÞ£¬·þÎñÆ÷Êý¾Ý¿âÒ²ºÜ°²È« ¡£ÔÚÍøÂç¸÷¹¤×÷վͨ¹ýWWWä¯ÀÀÆ÷¾ÍÄÜʵÏÖ¹¤×÷ҵΠ......
1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý¡£µ«ÊÇ£¬C++±Ï¾ ......
CÖеÄ#ºÅ²»½öÊÇ#include£¬#defineµÈµÄ¹Ø¼ü×ÖÊ×ʹÓöøÒÑ£¬#ÔÚºêÖл¹ÓкܶàÓ÷¨¡£¾ßÌåÇë¿´ÏÂÃæÎÒÀ´¾ÙÀý
1.Ë«#ºÅµÄºêÓ÷¨¡£
ÎÒÏàÐÅË«##ºÅµÄÓ÷¨Ó¦¸Ã´ó²¿·ÖÈ˶¼¼û¹ý°É£¬Ö÷ÒªÊÇÓÃÀ´Á¬½Óºê±äÁ¿ÃûʹÓã¬ÔÚGCC²Î¿¼ÊÖ²áÖÐÕâÑù¼ÇÔØ¡£
¿ÉÓÃÓÚºêÄÚ²¿½«Á½¸öÔ´´úÂëȨ±êÁ¬½Ó³ÉÒ»¸öµÄÁ¬½Óָʾ×Ö£¬¿ÉÓÃÀ´¹¹Ôì²»»á±»½âÎöÆ÷´íÎó½âÊ͵ÄÃû×Ö¡£ ......
CRTÔÏÈÊÇÖ¸Microsoft¿ª·¢µÄC Runtime Library£¬ÓÃÓÚ²Ù×÷ϵͳµÄ¿ª·¢¼°ÔËÐС£ºóÀ´ÔÚ´Ë»ù´¡ÉÏ¿ª·¢ÁËC++ Runtime Library£¬ËùÒÔÏÖÔÚCRTÊÇÖ¸Microsoft¿ª·¢µÄC/C++ Runtime Library¡£ÔÚVCµÄCRT/SRCĿ¼Ï£¬¿ÉÒÔ¿´µ½CRTµÄÔ´Â룬²»½öÓÐCµÄ£¬Ò²ÓÐC++µÄ¡£
CRTÔÏȵÄÄ¿µÄ¾ÍÊÇÖ§³Ö²Ù×÷ϵͳµÄÔËÐ ......