請幫助我,這段代碼是否正確?我的意思是,我們是否真的需要這個類中的dealloc方法,爲什麼我們或者不是?如果我們不在這裏使用dealloc,會是內存泄漏嗎? Thanx!帶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
出於好奇,這是爲了什麼? – outis 2010-10-29 09:38:16
我只是一個新的在這方面,我的魔杖到現在誰站在所有這些記憶的東西后面)) – yozhik 2010-10-29 10:28:10