Note that there are some explanatory texts on larger screens.

plurals
  1. POXcode: Displaying Data in Tables
    primarykey
    data
    text
    <p>Hello I am relatively new to the programming scene and have been using lynda.com to learn the skill and practice on small projects. I followed the instructors guidance to the letter, but our results are quite different. I want the "name" string of my course in my NSMutable Array to appear as the titles of the cells in my table but when I load the app nothing appears. Help a clueless kid out please!</p> <p>here is the code for my class, the implementation file just includes the synthesization for my properties </p> <pre><code>#import "Class.h" @implementation Course @synthesize name,teacher,room; @end </code></pre> <p>and here is the code for my UITable view controller class</p> <pre><code>#import "ScheduleTableViewController.h" @interface ScheduleTableViewController () @end @implementation ScheduleTableViewController NSMutableArray *classes; - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { NSMutableArray *classes = [[NSMutableArray alloc]init]; Course *class = [[Course alloc]init]; [class setName:@"AP Psychology"]; [class setRoom:@"E203"]; [class setTeacher:@"Juiliette Forbes"]; [classes addObject:class]; [class setName:@"AP Literature"]; [class setTeacher:@"Kristen Holtz"]; [class setRoom:@"E207"]; [classes addObject:class]; [class setName:@"AP Physics"]; [class setTeacher:@"Peter Dalby"]; [class setRoom:@"D205"]; [classes addObject:class]; [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [classes count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"ClassCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } Course *current = [classes objectAtIndex:indexPath.row]; [cell.textLabel setText:[current name]]; return cell; } </code></pre> <p>Any help will be well appreciated and hopefully I can keep up with any of the lingo</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload