concept table view in category ios

This is an excerpt from Manning's book Hello! iOS Development.
Later, the table view will ask for that data like this:
First, the table view asks its controller how many rows it should show
. To find out, the controller asks the fetched results controller
how many managed objects it has. Then the table asks for each row in turn
, which the controller gets by obtaining managed objects from the fetched results
. The last thing you need to do
is format the properties to look nice in the table. Let’s see the code.

This is an excerpt from Manning's book iOS Development with Swift.
Updating views— Several view types, such as image views or table views, display content that might need updating from a data source. The view controller is responsible for updating these views. The Facebook news feed is an example of a view that would need updating.
You’re going to add a table view to the Bookcase app, which will display a list of books in your bookcase. Then you’ll add tapping on a book in the list to edit the book in the form you’ve been working on. Let’s not get ahead of ourselves, though! For now, let’s focus on adding the table view to the app (see figure 9.2).
You have two main ways to set up a table view using Interface Builder:
You could drag a table view object onto your scene’s root view. You’d then need to connect the view controller to the table view—you’d make your scene’s view controller the delegate and data source for the table view and implement any required delegate methods. More on the delegate and data source of the table view shortly. You can drag a special type of view controller called a table view controller onto the storyboard. The table view controller comes with a table view ready to go and connected to the table view. All you need to focus on is customizing the table view to display your data.
Select the table view in the Document Outline. Notice in the Attributes Inspector that the content of the table view is using Dynamic Prototypes by default (see figure 9.5). Table views can use one of two types of cells: Because the books in the Bookcase app will eventually change over time, and each cell will have the same layout, a table view with dynamic prototypes is ideal for our example.
- Static cells— Use table views with static cells to build up a static design using a table. The number of rows in a table with static cells is set at design time, and each cell has its own unique design. A list of customizable settings in an app could be a good candidate for a table using static cells.
- Dynamic prototypes— Use table views with dynamic prototypes to build a table with content that can change at runtime and/or where cells have the same layout. A table view set to dynamic prototypes will automatically give you a prototype cell to customize the look of the cells in the table.
Select the white rectangle at the top of the table view, underneath the title Prototype Cells. This special table view cell is like a template that cells in your table will emulate.
Now that you have the table view controller set up in the storyboard, you’ll need to customize the table view in code. Select the table view controller and open the Identity Inspector. Note that the view controller’s base class is UITableViewController (see figure 9.6).
Replace the following methods in your BooksTableViewController class: The first two methods are straightforward. The number of sections in the table or rows in each section is returned from the methods. If multiple sections exist, you can check the section number the table view was asking about before returning the number of rows. (Because your table only has one section, it’s unnecessary to check the section number.) The third method is interesting. It receives an IndexPath parameter, which contains the number of the section and the row of the cell it’s interested in. It then gets a table view cell for this index path, based on the reuse identifier you defined earlier in Interface Builder. You can then customize the table view cell how you like. The index path is generally useful here to know what data to inject into the cell. The interesting thing about this method is where it gets its cell from. Imagine if you had a million rows in your table. It would start to be a major memory issue if the table view kept a million cells in memory. On the flip side, imagine if the app removed cells from memory as soon as they were scrolled offscreen and created new cells every time they scrolled onscreen. This strategy could be a performance issue, especially if the cells were graphically intensive. Apple’s shrewd solution is to keep a cache or queue of table view cells. When you call the dequeueReusableCell method, it first checks for any cells with the requested reuse identifier in the cache, and if none are found, it creates a new cell. When a cell is scrolled offscreen, rather than removing the cell from memory, it’s sent to the cache to be reused.override func numberOfSections( 1 in tableView: UITableView) -> Int { 1 return 1 12 } 1 override func tableView(_ tableView: UITableView, 3 numberOfRowsInSection section: Int) -> Int { 3 return 10 34 } 3 override func tableView(_ tableView: UITableView, 5 cellForRowAt indexPath: IndexPath 5 ) -> UITableViewCell { 5 let cell = tableView.dequeueReusableCell( 56 withIdentifier: "bookCell", for: indexPath) 56 cell.textLabel?.text = "Row # \(indexPath.row)" 57 return cell 58 } 5

This is an excerpt from Manning's book Anyone Can Create an App: Beginning iPhone and iPad programming.
Now you’ll connect the table view properties to the ViewController. While still in your storyboard, right-click the table view, and you’ll see the connections that are available for you by default, as shown in figure 15.1.
Connect the data to the table view.
Before you hook up the table view, take a minute to make the application code a little more readable and intuitive. Start by renaming your ViewController to MainView-Controller so you know this is the main one. Go to the Project Navigator (left panel), click ViewController once, and then click it again (but not as fast as a double-click) so that the word ViewController is highlighted (you can also Option-click it if you find that easier). Change the name of the file to MainViewController.swift. Open that file so it shows in the Standard Editor panel, and change the class definition as well. Change ViewController to MainViewController and then change the type from UIView-Controller to UITableViewController. Your class definition should now look like this:

This is an excerpt from Manning's book iOS 7 in Action.
Table view controllers (UITableViewController) contain a single table view. Table views allow you to display data as a list of rows represented by table view cells. These rows of data can also be visually separated and sectioned into groups.
A table view controller does much of the table view setup for you and doesn’t make you worry about manually plugging in the right methods to feed your table view with data. It’s common to use a regular view controller and manually add a table view to it without relying on a table view controller to do it for you. Depending on the kind of data you’re displaying or the complexity of your app, you may want more control over how your data is set up.
It’s inevitable that you’ll need to organize and display something as either a list or a grid. If you think of the applications you often use, you’ll realize that almost all of them have views where information is displayed to you in this manner. Our Hello Time app is one of the very few examples where you don’t display anything in a list or grid format. The Photos app shows a grid of all of your photos or videos using a collection view. The Contacts app shows a list of the people in your address book using a table view. The Settings app also uses a table view but lists different options you can choose from. These can be seen in figure 4.1.
Figure 4.1. The Contacts app and Settings app both use table views to display information as a list.
![]()
Earlier, you had a chance to use a table view when you created your Tasks application when exploring storyboarding. Now you’ll be able to spend more time specifically focusing on table views. As you’ve realized, almost all of the apps you use need to display information within a list or grid. By knowing the ins and outs of table views, you’ll be able to cover most of your bases. You’ll learn how to use table views in this chapter by using them in a single application to display albums and photos.
Another application that does just this is Apple’s own Photos application. You’ll essentially be making your own version of this app to display the exact same data. While doing this you’ll also use your first framework, the Assets Library. Your application will retrieve all of your albums and list them in a table view, as shown in figure 4.2.
This will be your second chance to use table views but your first time to really understand what’s going on under the hood. Imagine writing a list of information on a whiteboard or piece of paper. Each line within a list typically has one important item. The items you choose to write are distinctly separated because they’re on different lines. This is just like a grocery list or a real-world to-do list.
With the Tasks application you created a basic table view that displayed a list of tasks. For your purposes, a table view was the best way to represent your data. Imagine a task application that did not arrange your tasks into a list. Hard to picture, isn’t it? On the other hand, imagine if all of the photos in your Photos app were organized into a table view with only one photo per row. You could argue that this would result in too much wasted space because you could organize your photos in a grid to maximize the space you have available.

This is an excerpt from Manning's book iOS in Practice.
In the IB Attributes window, the selected class’s attributes are displayed, including their parent classes. For a UITableView, you’ll see the attributes for the table view on the top. Each subsequent parent class’s attributes appear below the previous class. In figure 3.2, you can see that the scroll view attributes appear under the table view attributes. The last item is the UIView’s attributes.
Table views are a natural fit for hierarchy navigation. With each selection you navigate down the hierarchy and slide in the applicable data. Table views provide a great means of viewing data and interacting with it. Viewing the list doesn’t need to be controlled by another mechanism—you interact directly with the list.
Start a new project in Xcode and select Master-Detail Application. Click Next, specify the product name as Dial4, specify the other settings, click Next, and set the location. Open the project’s Dial4MasterViewController.xib file under Resources and note the table view that appears (see figure 4.1).
A master-detail application defaults the first view controller to a table view controller. How convenient for you! Also, it reinforces the concept that table views lend themselves to navigation controllers and vice versa because often tapping on a row navigates to another controller. You could use other controllers instead of the navigation controller, but this one should be best for Dial4.
Default contents of row selection method for table view delegate
// Override to support row selection in the table view. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. // Create and push another view controller. /* <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; // ... // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; */ }
A table view isn’t much by itself. If you compile and run your project you’ll see an empty table. It needs not only to get data to display from somewhere, but also another class to handle any actions the user initiates. The table view uses a data source to provide its data and a delegate to handle the interactions.
Table views are vertical displays of data using rows or cells. Each cell displays text and/or images to allow the user to make their selection by tapping on the cell. In some cases, selection may not be allowed because the data may be for display only. Often you’ll see a disclosure indicator similar to (>) to indicate that the cell is selectable and leads to further details.

This is an excerpt from Manning's book iPhone in Action: Introduction to Web and SDK Development.
A Navigation-Based Application sets you up with a navigation controller, a nav bar along the top, and a table view in the middle of the page so that you can easily build hierarchical applications. We’ll also use it in chapter 15.
The standard iPhone paradigm is to do hierarchical navigation through table views, each of which contains lists of many different subpages that you can go to. As a result, despite the fact that any UIViewController could sit beneath a UINavigation-Controller, it’ll usually be a UITableViewController.