-2

That code is right? It doesn't dealloc and release it's saying that "super dealloc ARC forbids" when I need to do dealloc and when I need to do release?

#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
Rob
  • 371,891
  • 67
  • 713
  • 902
Benbo
  • 1
  • 1
  • You really have two questions here, and one of them has been thoroughly answered: you don't need to release items, even in dealloc, if you are using ARC. The 2nd question is what ARE release and dealloc: 'release' is a command (message) you give to an object to tell it to clear itself from memory. It means you're done with the object and don't need it anymore. 'dealloc' is a method in which you release objects. [super dealloc] is used in that method to tell the parent (super) class to run its own dealloc method. – leanne Aug 07 '13 at 19:08

2 Answers2

0

[super dealloc] and release are not permitted when using ARC. The goal of ARC is to manage this automatically so you don't need to worry about it. If you prefer to release your objects manually, then switching off ARC is the way to go.

Bo A
  • 3,087
  • 1
  • 29
  • 48
0

You cannot dealloc or release something if you are using arc. You can set _imageToDisplay to nil in dealloc.

Hetal Vora
  • 3,301
  • 2
  • 25
  • 53