I'm wondering if there is a way to check wether a variable that has been declared has been assigned or initialized 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){ };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With