OC8

it2024-10-31  16

// // Person.h // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> #import "Dog.h" @interface Person : NSObject @property (copy, nonatomic) NSString *name; @property (assign, nonatomic) NSInteger age; @property (retain, nonatomic) Dog *dog; @end // // Person.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import "Person.h" @implementation Person //copy展开 - (void)setName:(NSString *)name { if (_name != name) { [_name release]; _name = [name copy]; } } //assgin展开 - (void)setAge:(NSInteger)age { _age = age; } //retain展开 - (void)setDog:(Dog *)dog { if (_dog != dog) { [_dog release]; _dog = [dog retain]; } } - (void)dealloc { [_name release]; [_dog release]; [super dealloc]; } @end // // Dog.h // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> @interface Dog : NSObject @end // // Dog.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import "Dog.h" @implementation Dog @end // // main.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); } return 0; }

 

转载于:https://www.cnblogs.com/0515offer/p/4586965.html

最新回复(0)