属性是否需要解除分配?

时间:2010-05-11 17:42:29

标签: iphone objective-c cocoa cocoa-touch xcode

我继承了NSObject:

#import <Foundation/Foundation.h>


@interface STObject : NSObject {
    NSString *message_type;
    NSString *twitter_in_reply_to_screen_name;
}

@property(nonatomic, copy) NSString *message_type;
@property(nonatomic, copy) NSString *twitter_in_reply_to_screen_name;

@end

我的实现如下:

#import "STObject.h"

@implementation STObject
@synthesize message_type, twitter_in_reply_to_screen_name;

@end

我是否需要为我释放字符串的两个属性创建一个dealloc方法?

1 个答案:

答案 0 :(得分:4)

是。使用-release时,属性不会自动为@synthesize

-(void)dealloc {
   [message_type release];
   [twitter_in_reply_to_screen_name release];
   [super dealloc];
}