in Technology by (1.9m points)

What happen if we send any message to an object which is released?

1 Answer

0 votes
by (1.9m points)

Calling release on an object does not necessarily mean it’s going to be freed. It just decrements the object’s retain count. It’s not until the retain count reaches 0 the object gets freed (and even then, the object might be in an autorelease pool and still not be freed quite then).

So, you might release your object but you could still be pointing to it. And then it could get autoreleased. And then you send it a message — but maybe the object is garbage now.

Related questions

0 votes
asked Oct 24, 2021 in Education by JackTerrance (1.9m points)
0 votes
asked Oct 21, 2021 in Education by JackTerrance (1.9m points)
...