在我viewController.m
我有這樣的代碼:請幫我看看這個iOS的代碼,這兩個泄漏
self.movie = [[myMovie alloc]init];
self.movie.name = @"Iron man 2"; \\this line leaks
...
nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(30, 20, 200, 20)]; \\this line leaks
nameLbl.backgroundColor = [UIColor clearColor];
在viewController.h
我有這樣的代碼:
@interface ViewController : UIViewController
{
myMovie * movie;
UILabel * nameLbl;
}
@property (nonatomic, retain) myMovie * movie;
@property (nonatomic, retain) UILabel * nameLbl;
and myMovie.h:
{
NSString* name;
}
@property (nonatomic, retain) NSString* name;
myMovie.m:
#import "myMovie.h"
@implementation myMovie
@synthesize name, gross, desc;
-(void) dealloc
{
self.name = nil;
self.gross = nil;
self.desc = nil;
[super dealloc];
}
@end
當然,這只是必要的代碼。我無法弄清楚它爲什麼會泄漏。我不知道這是否是原因,但我的應用程序崩潰。
什麼告訴你該線路泄漏? – 2012-02-18 13:07:54