1

I'm very new to Objective C programming. For some reason, the line indicated below in an arrow gives me an "ARC forbids explicit message send of 'release'" message. Can someone please explain what I'm doing wrong here?

int main(int argc, char *argv[]) {
    @autoreleasepool {
        Person *morgy;
        morgy = [Person alloc];
        morgy = [morgy init];

        [morgy setWeight: 145];
        [morgy setAge: 19];
        [morgy print];
        [morgy release]; // <------
    }

    return 0;
}
solgar
  • 4,312
  • 2
  • 26
  • 30
Vimzy
  • 1,871
  • 8
  • 30
  • 56

1 Answers1

1

ARC is automatic reference counting. It automatically releases objects for you when nothing is retaining it anymore. Explicitly releasing it would defeat the purpose and break the whole engine. So, it is not allowed.

Simply delete the line, it is not necessary in ARC.

Theis Egeberg
  • 2,556
  • 21
  • 30