zoukankan      html  css  js  c++  java
  • OC8_setter方法展开

    //
    //  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;
    }
  • 相关阅读:
    百度脑图
    Bootstrap入门
    Tomcat热部署的三种方式
    There is a chart instance already initialized on the dom!警告
    Ubuntu14.04设置开机自启动脚本
    PRM路径规划算法
    A*算法
    V-rep学习笔记:串口操作
    V-rep学习笔记:机器人路径规划2
    V-rep学习笔记:机器人逆运动学解算
  • 原文地址:https://www.cnblogs.com/0515offer/p/4586965.html
Copyright © 2011-2022 走看看