I've looked at some of the previous answers here to a similar question, but I still don't understand.
Here is the code (from ShareKit)
if (isDismissingView)
return;
NSLog(@"presentingViewController: %@", [self.currentView presentedViewController]);
if (self.currentView != nil)
{
// Dismiss the modal view
if ([self.currentView parentViewController] != nil)
{
self.isDismissingView = YES;
[[self.currentView parentViewController] dismissModalViewControllerAnimated:animated];
}
// for iOS5
else if ([self.currentView respondsToSelector:@selector(presentingViewController)] && [self.currentView presentingViewController]) {
//****** it executes this block ******
self.isDismissingView = YES;
[[self.currentView presentingViewController] dismissViewControllerAnimated:animated completion:^{ ... }
}
else
self.currentView = nil;
}
At the NSLog, the result is (null)
, which apparently is not the same as nil, because the block that tests if it is not nil
else if ([self.currentView respondsToSelector:@selector(presentingViewController)] && [self.currentView presentingViewController])
is executed.
So I have three questions. What is (null)
? How does an object or pointer become (null)
? What is the right way to test this condition?