Working with Multiple View Controllers

With our switch to a table view as the main interface for our Twitter app, we’re starting to resemble and work like the many other Twitter apps on iOS. However, our functionality is limited: all we can do is load and display the tweets. In fact, we’ve actually lost the “Send Tweet” functionality, because the full-screen table view doesn’t afford a good place for its button. So what are we going to do?

Usually, iOS tables do something when the user clicks on a table row. And most of the time, that something is to show the details of the thing that was clicked on, with a new interface appropriate to the detail view.

What’s happening in that case is that iOS is presenting a different view controller, one that is designed specifically for the task at hand. So for our app, that means we want to go from the view controller that shows all the tweets to one that shows just the specifics of one tweet. From here, we could go to another view controller: for example, we could click on the tweeter’s profile image to go to a view controller that shows details about him or her. Each view controller is built for one task—showing all the tweets, showing the details of one tweet, showing the details of the Twitter user—which allows us to divvy out functionality to different classes within our codebase.

To start adding new view controllers to our application, we’ll want to make a few changes to our source code. We need the ability to arbitrarily grow our application by adding new classes and new storyboard scenes, and we need to start thinking about where we are going to put new code, and where we have opportunities for code reuse. All in all, it’s a good time to tackle some much needed refactoring.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.109.148