开发者

In obj-c, do i have to initialise values eg pointers, or are they auto initialised to nil?

开发者 https://www.devze.com 2023-03-03 20:35 出处:网络
In obj-c, do i have to initialise values eg pointers, or are they auto 开发者_Python百科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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号