【发布时间】:2012-03-17 00:43:31
【问题描述】:
我在iPhone - dealloc - Release vs. nil 找到了一个有点相关的问题,但它没有回答我的问题。
我在故事板中创建了一个按钮、一个UIScrollview 和一个标签。当我 Ctrl 将对象拖到 ViewController.h 时,他们创建了这个:
@interface ViewController : UIViewController{
__weak IBOutlet UIScrollView *scroller;
}
@property (weak, nonatomic) IBOutlet UIButton *goButton;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIScrollView *scroller;
- (IBAction)pressGo:(id)sender;
@end
在 ViewController.m 的顶部我有:
@implementation ViewController
@synthesize goButton;
@synthesize label;
@synthesize scroller;
它在viewDidUnload 中创建了:
[self setGoButton:nil];
[self setScroller:nil];
[self setLabel:nil];
scroller = nil;
[super viewDidUnload];
全部自动创建。我见过很多对dealloc 和release 的引用。
这段代码,预制的东西,会防止内存泄漏吗?或者我必须添加dealloc?
对于我所犯的任何错误,我深表歉意……我是新手。
【问题讨论】:
标签: objective-c xcode4.2 null dealloc