A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 13717407086 中级黑马   /  2016-5-23 23:56  /  794 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

//
//  TXWGoods.m
//  谭显文作业
//
//  Created by jolly on 16/5/23.
//  Copyright © 2016年 jolly. All rights reserved.
//

#import "TXWGoods.h"

@implementation TXWGoods
-(void)setName:(NSString *)name{
    if (_name != name) {
        [_name release];
        _name = name;
        [_name retain];
    }
   
}
-(NSString *)name{
    return _name;
}
-(void)setPay:(int)pay{
    _pay = pay;
}
-(int)pay{
    return _pay;
}
-(void)setWeight:(float)weight{
    _weight = weight;
}
-(float)weight{
    return _weight;
}
-(void)setPicture:(TXWPicture *)picture{
    if (_picture != picture) {
        [_picture release];
        _picture = picture;
        [_picture retain];
    }
   
}
-(void)dealloc{
    NSLog(@"商品完了");
    [_name release];
    [_picture release];
    [super dealloc];
}
-(TXWPicture *)picture{
    return _picture;
}
-(void)setProduceDate:(produceDate )pDate{
    _pDate = pDate;
}
-(produceDate)pDate{
    return _pDate;
}
-(void)setExpireDate:(expireDate )eDate{
    _eDate = eDate;
}
-(expireDate)eDate{
    return _eDate;
}
-(instancetype)initWithName:(NSString *)name andPay:(int)pay andWeight:(float)weight andPicture:(TXWPicture *)picture andPDate:(produceDate)pDate andEDate:(expireDate)eDate{
    if (self = [super init]) {
        _name = name;
        _pay = pay;
        _weight = weight;
        _picture = picture;
        _pDate=pDate;
        _eDate = eDate;
    }
    return self;
}
+(instancetype)goodsWithName:(NSString *)name andPay:(int)pay andWeight:(float)weight andPicture:(TXWPicture *)picture andPDate:(produceDate)pDate andEDate:(expireDate)eDate{
    return [[self alloc]initWithName:name andPay:pay andWeight:weight andPicture:picture andPDate:pDate andEDate:eDate];
}

@end

为什么我在外面调用类方法创建对象不会retainCount+1啊



0 个回复

您需要登录后才可以回帖 登录 | 加入黑马