0
votes

Apologies if this is duplicate. If so I am thankful for a link and happy to delete my question. However, I did not find an answer between tons of search results. This is not the usual case of unrecognized selectors. The selector is nil. And it is thrown on this very line:

return self.topViewController;

That line is embedded in:

@implementation UINavigationController (JTRevealSidebarV2)

- (UIViewController *)selectedViewController {
    return self.topViewController;
}

@end

As you see it is an attempt to extend UINavigationController. You may have noticed that my code is based on this turorial: https://github.com/mystcolor/JTRevealSidebarDemo (Based on the Demo of Version 2, if anybody is interested).

As far as I have noticed I have not yet made any change to mystycolor's framework. Especially not UIViewController+JTRevealSidebarV2.h nor .m. So far I only made changes to one of the two view controllers, that are presented. Those, that contain the contents, not the navigation logic.

Apparently the method is being called. Therefore the category must have been used in some correct way? And all what mystycolor is using there, he calls a well documented method and returns its value. As it is from a tutorial, which is foreign code, do not ask me why topViewController is not called directly. I will try that next of course, but even if that helps I'd still be courius about what went wrong here.

Just out of curiosity I did change that expression to return [self topViewController];, but no surprise that did not make a change.

I am happy to provide more code but don't know which sniplet may be interesting for you to help.

1

1 Answers

0
votes

This is not an answer to the question WHY but I found out what I made wrong.

One fo the view controllers I was working with did not include

#import "UIViewController+JTRevealSidebarV2.h"
#import "UINavigationItem+JTRevealSidebarV2.h"

The method selectedViewController is implemented for both categories but does different things when being called. That is the answer to the question why mystycolor did implement it that way.

And now that I added these includes it works fine.

But to me the error message is still confusing. How could it be that the method was called at all, when the reason for the error appears to be that the extension, of which the method is part of, was not included everywhere?