Re:nil, Nil, NULL, NSNull
by seanalltogether on Monday January 07, 2013 @11:38AM
(#5021794)
Also for what its worth, variable declarations are not nil by default, this bug tied me up for quite some time.
this can send you on a wild goose chase for not declaring val = nil initially.
[ Parent
| on HN ]
This is no longer true when using ARC. See the "Stack Variables Are Initialized with nil" section of http://developer.apple.com/library/ios/#releasenotes/Objecti...
"Using ARC, strong, weak, and autoreleasing stack variables are now implicitly initialized with nil."
This doesn't affect plain C variables, but it would solve the issue you had above.
That's a rule of C; stack vars are not initialized. Same thing would happen with an int.
Member variables of a class are set to zero by (init or alloc? can't remember.)
And, if you don’t or can’t use ARC, turn on -Wuninitialized or use the static analyzer (clang warns on uninitialized values only with -Wall).