我的项目中有这个类的标题:
@interface VideoItem : NSObject <NSCoding> {
NSString *idStr;
NSString *name;
NSString *link;
}
-(id)initWithVideoItem:(VideoItem*)video;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *link;
@property (nonatomic, retain) NSString *idStr;
@end
这是工具:
@implementation VideoItem
@synthesize name,link,idStr;
-(id)initWithVideoItem:(VideoItem*)video{
if (self = [super init]) {
self.name = video.name;
self.link = video.link;
self.idStr = video.idStr;
}
return self;
}
#pragma mark
#pragma mark NSCoder
- (void)encodeWithCoder:(NSCoder *)encoder{
[encoder encodeObject:self.name forKey:@"video_name"];
[encoder encodeObject:self.link forKey:@"video_link"];
[encoder encodeObject:self.idStr forKey:@"video_id"];
[encoder encodeObject:self.imgUrl forKey:@"video_img"];
[encoder encodeObject:self.viewCount forKey:@"video_views"];
[encoder encodeObject:self.artist forKey:@"video_artist"];
[encoder encodeObject:self.timeStr forKey:@"video_timestr"];
[encoder encodeInt:self.seconds forKey:@"video_secondes"];
[encoder encodeInt:self.rating forKey:@"video_rating"];
[encoder encodeObject:self.pubDate forKey:@"pubDate"];
}
- (id)initWithCoder:(NSCoder *)decoder {
if(self = [super init]){
self.name = [decoder decodeObjectForKey:@"video_name"];
self.link = [decoder decodeObjectForKey:@"video_link"];
self.idStr = [decoder decodeObjectForKey:@"video_id"];
}
return self;
}
@end
我想知道在这种情况下我是否需要添加dealloc
方法并释放字符串?