Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems displaying array from plist in tableview cell
    text
    copied!<p>I want to read and display my arrays in my Stages dict into the tableview. However, my app crashes and give the error message: <em>*</em> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x4b43ee0'</p> <p>I am able to display the number of rows for the arrays in the Stages dict but not able to display the name inside the table cell.</p> <p>Below is my plist and codes.</p> <blockquote> <p>Root (Array)</p> <pre><code> Item 0 (Dict) Project Name (String) Stage (Dict) Analysis (Array) Design (Array) Develop (Array) Implement (Array) </code></pre> </blockquote> <p>In my viewDiDLoad method, i called</p> <pre><code> //course is a nsdictionary which is pass down from the previous view stages = [course objectForKey:@"Stage"]; </code></pre> <p>tableview methods</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger rows = 0; if (section == 0){ rows = 1; } if (section == 1) { return [stages count]; } return rows; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"StagesCellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 } // Set up the cell if (indexPath.section == 0) { if (indexPath.row == 0) { cell.textLabel.text = @"Project Name"; cell.detailTextLabel.text = [course objectForKey:@"ProjectName"];; } } if (indexPath.section == 1) { cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; NSString *cellvalue = [stages objectAtIndex:indexPath.row]; cell.textLabel.text = cellvalue; } return cell; } </code></pre> <p>Thanks in advance(:</p>
 

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