// // 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啊
|