In obj-c, do i have to initialise values eg pointers, or are they auto initialised to nil?
In obj-c, do i have to initialise values eg pointers, or are they auto 开发者_Python百科initialised to nil?
Eg:
- (void) myfunc {
EpgSparseEntry *onNow=nil, *next=nil, *later=nil;
}
Do i need the =nil , or can i assume that variables on the stack are initialised to zero/nil?
Thanks
Can i assume that variables on the stack are initialised to zero/nil?
No. Variables on the stack are not initialized so they contain random data.
That's different from an object's instance variables because all the memory an object occupies is zeroed out upon allocation.
精彩评论