Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy aren't my NSMutableArray objects being added to the UITableView straight away?
    primarykey
    data
    text
    <p>I have an NSMutableArray with objects within it and I use the following code to add/remove objects from the UITableView. It works but only after closing and relaunching the app, not straight away. Why is this? Here is my code (maincelltext is the title in the cell and subtitlecelltext is the subtitle):</p> <pre><code>maincelltext = [[NSMutableArray alloc] init]; subtitlecelltext = [[NSMutableArray alloc] init]; [maincelltext addObject:@"TITLE"]; [subtitlecelltext addObject:@"SUBTITLE TEST"]; </code></pre> <p>EDIT: Here is my UITableView code:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.textLabel.font = [UIFont fontWithName:@"HelveticaBold" size:16.0]; cell.textLabel.adjustsFontSizeToFitWidth = YES; cell.textLabel.numberOfLines = 1; // Configure the cell. UIImage *cellImage = [UIImage imageNamed:@"warning.png"]; CGRect cropRect = CGRectMake(0.0, 0.0, 12.0, 12.0); CGImageRef croppedImage = CGImageCreateWithImageInRect([cellImage CGImage], CGRectMake(0.0f,0.0f,cellImage.size.width,cellImage.size.height)); UIImageView *myImageView = [[UIImageView alloc] initWithFrame:cropRect]; [myImageView setImage:[UIImage imageWithCGImage:croppedImage]]; CGImageRelease(croppedImage); [self.view addSubview:myImageView]; cell.imageView.image = cellImage; NSString *subjectString = [maincelltext objectAtIndex: [indexPath row]]; cell.textLabel.text = subjectString; NSString *subtitle = [subtitlecelltext objectAtIndex: [indexPath row]]; cell.detailTextLabel.text = subtitle; if(maincelltext.count == 0){ NSString *notabledata = [NSString stringWithFormat:@"No Dates Set"]; [maincelltext addObject:notabledata]; } return cell; } </code></pre> <p>Thanks!</p>
    singulars
    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