那个代码是对的? 它没有dealloc并释放它说“超级dealloc ARC禁止” 什么时候我需要做dealloc和什么时候需要释放?
#import "ImageViewController.h"
@interface ImageViewController ()
@end
@implementation ImageViewController
@synthesize imageToDisplay=_imageToDisplay;
-(IBAction)click:(id)sender
{
if ([[sender title]isEqualToString:@"Dog"])
{
[_imageToDisplay setImage:[UIImage imageNamed:@"border-collie_177061-1280x1024.jpg"]];
}
else if ([[sender title]isEqualToString:@"FakeBook"])
{
[_imageToDisplay setImage:[UIImage imageNamed:@"images.jpeg"]];
}//else if
}//click
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)dealloc
{
[_imageToDisplay release];
[super dealloc];
}
@end
答案 0 :(得分:0)
[super dealloc]
和release
。 ARC的目标是自动管理它,因此您不必担心它。如果您希望手动释放对象,则可以关闭ARC。
答案 1 :(得分:0)
如果使用弧线,则无法释放或释放某些内容。您可以在dealloc中将_imageToDisplay设置为nil。