Are instance variables set to nil by default in Objective-C?

后端 未结 3 1431
情书的邮戳
情书的邮戳 2020-12-15 15:53

I\'m sorting out some memory issues with my iPhone app and I\'ve just been thinking about some basics. If I setup an ivar and never end up using it in the lifespan of my obj

3条回答
  •  悲&欢浪女
    2020-12-15 16:28

    Yes, ivars are always initialized to 0/nil/NULL/NO/etc.

    However, if it helps you understand what's going on, go for it. The performance impact is negligible. You don't need to do it, but it won't cause any problems if you do.

提交回复
热议问题