IOS?????property???
???????????? ???????[ 2014/11/21 14:50:04 ] ??????????????? ?????? iOS
???????????????????????е?Property?????е???Щ????????????????release????????self.xxx = nil;??????Objective-c???????????cocos2d?????????????????????????????objc????@property???????????????????atomic??nonatomic??readonly??readwrite??assign??retain??copy??getter??setter??Щ?????????????????????????????Objc?????????cocos2d?????????????????????????Ray??3???????????????????????????????????????@property??
???????c/c++???????????????????struct/class????????????????????public??protected??private???????public??????????????????????.????????????????????????????
????//in Test.h
????class Test
????{
????public:
????int i;
????float f;
????};
????????main?????????????????????????????????????????????main???????????????????????????????????????e?main.m???main.mm????????Щ?????????????κ???????????c??????????????????????????????????????????????.mm???????????????????????????????.mm?????
????//in main.mm
????Test test;
????test.i =1;
????test.f =2.4f;
????NSLog(@"Test.i = %d?? Test.f = %f"??test.i?? test.f);
???????????objc???棬????????????????????????????????????objc???????BaseClass??
????//in BaseClass.h
????@interface BaseClass : NSObject{
????@public
????NSString *_name;
????}
??????????????????main.mm???棺
????BaseClass *base= [[BaseClass alloc] init];
????base.name =@"set base name";
????NSLog(@"base class's name = %@"?? base.name);
??????????????xcode4??????????????????
??????????????????“Property 'nam' not found on object of type BaseClass*"????????BaseClass?????????????name????????????????????????????@public?????????????????BaseClass???????.??????????????????????@public??@protected??@private??????????????????????????????@private????????????????????????????????????????г????????c++??java????????
????????д???????????????????????????????@property?????????????property????????
????//in BaseClass.h
????@interface BaseClass : NSObject{
????@public
????NSString *_name;
????}
????@property(nonatomic??copy) NSString *name;
????//in BaseClass.m
????@synthesize name = _name;
????????????????У?ok????á?????????????@prperty?????????”."?????????????????@property???????.??????????????????????????????????????????
@interface BaseClass : NSObject{
@public
NSString *_name;
}
//@property(nonatomic??copy) NSString *name;
-(NSString*) name;
-(void) setName:(NSString*)newName;
???@property??????????????????????????????name??setName????????????????
//@synthesize name = _name;
-(NSString*) name{
return _name;
}
-(void) setName:(NSString *)name{
if (_name != name) {
[_name release];
_name = [name copy];
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11