2014-12-10

Practice Final -Problem 3.

Team Members: Swathi Kotturu, Farjahan Hossain, Michael Singh; For ios platform, the table view is a user interface object that allow the programmer to manage taps on rows or any other actions. Each cell in a table is given by a UITableViewCell.Tables get their configuration info by two objects set on them: an object implementing the UITableViewDelegate protocol and an object implementing the UITableViewDataSource protocol.
  1. import < UIKit/UIKit.h>
  2. include < sys/types.h>
  3. include < sys/socket.h>
  4. include < netinet/in.h>
  5. include < netdb.h>
@interface ViewController : UIViewController
	< UITableViewDelegate, UITableViewDataSource> 
@property (nonatomic, copy) NSArray *listData;
@end // // ViewController.m // NetworkExample // // Created by Chris Pollett on 10/29/14. // Copyright (c) 2014 Chris Pollett. All rights reserved. //
  1. import "ViewController.h" @interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    char msg[] = "HELLO\n";
/*
  This method gives for each section in the table the number of rows
  it has (we only have one section so in this case it returns the total
  number of rows)
  • / -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
        return [self.listData count];
    
    }
  • /*
       This method is a callback used to fill in table cells. Notice to save
       memory we only instiate cells which will be scene, but then we cache
       them when they become invisible
     */
    
    -(UITableViewCell *)tableView: (UITableView *)tableView
            cellForRowAtIndexPath:(NSIndexPath *)indexPath
    
    {
        /* Name we will use for our type of table cell (if have more than one type)
           we might have more than one name. For example, we might have image and
           non image cells
         */
        static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    
        UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    
        if(cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                           reuseIdentifier: SimpleTableIdentifier];
        }
    
        NSUInteger row = [indexPath row];
    
        cell.textLabel.text = self.listData[row];
        /* If we want to style our cells we can do things like:
         cell.textLabel.font = [UIFont boldSystemFontOfSize:50];
         */
        return cell;
    
    }
    @end
    Team Members: Swathi Kotturu, Farjahan Hossain, Michael Singh; For ios platform, the table view is a user interface object that allow the programmer to manage taps on rows or any other actions. Each cell in a table is given by a UITableViewCell.Tables get their configuration info by two objects set on them: an object implementing the UITableViewDelegate protocol and an object implementing the UITableViewDataSource protocol. #import < UIKit/UIKit.h> #include < sys/types.h> #include < sys/socket.h> #include < netinet/in.h> #include < netdb.h> @interface ViewController : UIViewController < UITableViewDelegate, UITableViewDataSource> @property (nonatomic, copy) NSArray *listData; @end // // ViewController.m // NetworkExample // // Created by Chris Pollett on 10/29/14. // Copyright (c) 2014 Chris Pollett. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; char msg[] = "HELLO\n"; /* This method gives for each section in the table the number of rows it has (we only have one section so in this case it returns the total number of rows) */ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { return [self.listData count]; } /* This method is a callback used to fill in table cells. Notice to save memory we only instiate cells which will be scene, but then we cache them when they become invisible */ -(UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { /* Name we will use for our type of table cell (if have more than one type) we might have more than one name. For example, we might have image and non image cells */ static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: SimpleTableIdentifier]; } NSUInteger row = [indexPath row]; cell.textLabel.text = self.listData[row]; /* If we want to style our cells we can do things like: cell.textLabel.font = [UIFont boldSystemFontOfSize:50]; */ return cell; } @end
    X