Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C uninitialized pointers vs null pointers

Maybe my memory has gone completely wacko, but I think I remember that declaring pointers without initializing them made them point to nil. But recently this doesn't seem to be the case. Has it always been this way? Or has it something to do with the compiler settings?

like image 317
quano Avatar asked Oct 24 '09 21:10

quano


1 Answers

Instance variables of objects are initialized to nil in alloc (the whole object is bzeroed).

Edit: Also, global and static storage variables are initialized to zero (6.7.8 10 of the C99 Standard, thanks Derek for pointing that out).

Local stack variables are not initialized automatically. This did not change in known history.

like image 67
Nikolai Ruhe Avatar answered Sep 28 '22 07:09

Nikolai Ruhe