Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing NSMutableArray for UITableviewcell
    primarykey
    data
    text
    <p>I am trying to use an NSMutableArray to build my tableview's datasource. The NSMutableArray is empty. </p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.ingredientsArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // Configure the cell... if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.textLabel.text = [self.ingredientsArray objectAtIndex:indexPath.row]; return cell; } </code></pre> <p>I have a 'Add' button so users enter their ingredients in a textfield and this is added to the array. There is nothing wrong with the array getting loaded. There is something wrong with the cell.textLabel.text = [self.ingredientsArray objectAtIndex:indexPath.row]; But I cannot put my finger on it. I have look on the site and seen a couple of answers to similar questions but they do not seem to work. I have tried changing the numbersinrow: method to a value and the app doesn't compile. </p> <p>I then added an object to the NSMutablearray in view did load. Changed the numberOfRowsinSection: method to 1 and in the cellForRowAtIndexPath: kept that the same and I was able to see the test String that I put in. However this is not what I am going for. </p> <p>I want a user to enter a string (ingredient) in the text field and for this to be displayed in the tableview underneath. Now when I add strings to the NSMutableArray they are not displayed in the tableview just the one test string is present. They are getting added correctly as I have nslog'd it to check. </p> <p>Any help or advice is greatly appreciated!</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.
    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