开发者

How to check if an object was initialized? Objective-C

I'm wondering if there is a way to check wether a variable that has been declared has been assigned or initiali开发者_如何学JAVAzed or not in Objective C..

thank you


All instances variables are set to 0 (or nil for objects) in the alloc method, see The Objective-C Programming Language.

This means you can check the variable with

if (!var) {...}

Be aware though that there is no way to differentiate between the state after initialization or just being set to 0.


Check if the object is 'nil':

if(object == nil){ };
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜