I was confused by such output result of this program.
#import <Foundation/Foundation.h>
#import "Human.h"
int main(int argc, const char * argv[]) {
Human *human = [Human new];
[human release];
[human sayHello];
return 0;
}
The class itself is
@implementation Human
-(void)sayHello {
NSLog(@"Hello");
}
-(void)dealloc {
NSLog(@"Deallocated");
[super dealloc];
}
@end
The result is Output result
The main question is why method sayHello
was executed though object itself was destroyed as its retain count was set to 0
by sending release
message? What's more important that if I go through the program flow via debugger, the application will crash cause human
pointer is not an object anymore. What's happening here?
P.S. ARC is turned off
Thanks in advance.