views:

69

answers:

1

Hey guys,

I'm observing UINavigationControllerWillShowViewControllerNotification on UINavigationController to keep track when the current view controller has been popped, as suggested on this post.

There's literally no reference anywhere for that notification and a Google search will link me only to that post.

Does it mean this is a private notification and my app could be rejected?

Even worse: does it mean I shouldn't trust how that notification works as it might break in a future SDK version?

+1  A: 

The notification in question is actually implicitly referenced in the documentation:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

Delegate methods are, at least in Cocoa for Mac OS X usually accompanied by a notification (well, often times, anyway).

As it stands it's an undocumented feature, and as such should be treated with care. If possible, use the delegate method instead.

However: If it appears in the header, and it works, and it is accompanied with a delegate method; it is possible that this is a documentation oversight on Apple's side; and that using it is safe.

I recommend filing a bug and see where that gets you; at least if restructuring your application to use a delegate directly would be overly cumbersome (more cumbersome than filing a bug).

Williham Totland
And if one were really paranoid about this falling under the "private API" umbrella, he/she could implement the delegate method and then fire a custom notification for other objects to observe.
Steve Madsen
Don't even need to be a custom one; it could just be `UINavigationControllerWillShowViewControllerNotification`. :)
Williham Totland
The notification itself doesn't appear on the headers - there's no constant for it, I'm using an actual NSString for it's name. And, actually, this is different from the delegate method. When I get the notification, the navigation stack is still intact and I have on the user info dictionary both the last visible navigator and the next visible navigator. So I have which view controller is being popped from the stack - something I can't do with the delegate method alone.
leolobato
File a bug, then. It's clearly and undocumented feature, but it might not be by design. Even if only two applications so far need it, it does appear to be fully functional. Here I think the best is to ask Apple for clarity.
Williham Totland