in Technology by (1.8m points)

What happens when we invoke a method on a nil pointer?

1 Answer

0 votes
by (1.8m points)

A message sent to a nil object is perfectly acceptable in Objective-C, it’s treated as a no-op. There is no way to flag it as an error because it’s not an error, in fact it can be a very useful feature of the language. It returns 0, nil, a structure filled with 0s, etc.

Related questions

0 votes
asked Oct 24, 2021 in Education by JackTerrance (1.8m points)