I have read the docs from apple http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/WorkingwithObjects/WorkingwithObjects.html
It says that we can check if object is null like…
XYZPerson *somePerson;
// somePerson is automatically set to nil
if (somePerson != nil) {
// somePerson points to an object
}
Most probably i am doing something wrong but need your help to find what it is.
I have a class C2,I create the C2 object but not initialising,when checking with the code below ,app writes NOT NİL to output.What am i doing wrong.
Thanks for your help.
C2 * o3;
if (o3 != nil) {
NSLog(@"NOT NİLLLL");
}else{
NSLog(@"NOT");
}
Unlike members of classes that are zeroed out on initialization, local variables are not initialized automatically by pre-ARC compilers. If you would like your local
o3to benil, you need to initialize it yourself:The behavior of not initializing locals unless explicitly directed by the program comes from C: there, too, the locals are not initialized by default.