I am trying to figure out how to design a search bar I am implementing in my application and needed guidance on good coding practice. I have a search bar, that upon editing the search bar, a popup controller will appear displaying historical results. My search bar works very closely to that of Apple's example located here: http://developer.apple.com/library/ios/samplecode/ToolbarSearch/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009461
Goal: I want a modular, self-contained implementation that say, if someone wanted to reuse my code, they could just copy the class and use the search bar. (And of course other obvious things, readable, clean, efficient, etc.)
The way Apple does it in their example is having two different classes. The first is a controller for the search bar itself and it manages a popover view. They have a second class that is a subclass of a UITableViewController that manages recent results. The first class then leverages the second within the popover controller.
My issue with this approach is that both classes are coupled and it doesn't make sense to me why they need to two different classes. So what would be the best way to structure this: refactoring into a single class, making a helper class, leave as is, etc. Any guidance is appreciated.