Philip007
Philip007

Reputation: 3230

Methods invoked by runtime in Objective-C

Today I read the apple documentation on dealloc. It reads that

"You never send a dealloc message directly. Instead, an object’s dealloc method is invoked by the runtime."

In my understanding, it means that we never send dealloc message to an object, only runtime sends dealloc to itself. Correct me if I am wrong.

In addition, I am wondering what other methods are only invoked by runtime just like dealloc.

I read the runtime reference, but had a hard time to understand it. Let's say, why dealloc is not listed in the doc?

Upvotes: 0

Views: 98

Answers (1)

Amy Worrall
Amy Worrall

Reputation: 16337

In my understanding, it means that we never send dealloc message to an object

Correct.

only runtime sends dealloc to itself

The runtime sends dealloc methods to objects when their retain count gets to zero. The runtime doesn't send dealloc to itself (the runtime isn't an object, and deallocating the runtime doesn't make sense!).

Upvotes: 2

Related Questions