【发布时间】:2010-10-29 09:32:29
【问题描述】:
请帮助我,这段代码正确吗?我的意思是,我们真的需要在这个类中使用 dealloc 方法吗,为什么需要或不需要呢?如果我们在这里不使用 dealloc 会不会是内存泄漏? 谢谢!
#import <Foundation/Foundation.h>
@interface MyData : NSObject
{
@private
NSString *name;
NSString *surname;
NSString *email;
NSString *telephone;
UIImage *image;
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *surname;
@property (nonatomic, retain) NSString *email;
@property (nonatomic, retain) NSString *telephone;
@property (nonatomic, retain) UIImage *image;
@end
#import "MyData.h"
@implementation MyData
@synthesize name;
@synthesize surname;
@synthesize email;
@synthesize telephone;
@synthesize image;
- (void) dealloc
{
[name release];
[surname release];
[email release];
[telephone release];
[image release];
[super dealloc];
}
@end
【问题讨论】:
-
出于好奇,这是干什么用的?
-
我只是这个领域的新人,我想知道现在谁支持所有这些记忆的东西))
标签: objective-c ios4 release dealloc