title: iPhone - Array to UITableView
body: <p>I can't display array in UITableView. The thing I do is - in viewWILLappear I'm creating array. In viewDIDappear I'm filling the array. But when I run <code>[myArr count]</code> or <code>[myArr objectAtIndex:indexPath.row]</code> in table setup I get empty table. If I define constant integer as row count and some constant string as cell text everything works fine. Is there some populate() method I have to run or is it a problem with some order of declarations?</p>
  
  <p>Thanks for any help. Here's the code:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated {
      myArr = [[NSMutableArray alloc] initWithCapacity:100];
  }
  - (void)viewDidAppear:(BOOL)animated {
      [self load_array];
  }
  - (void) load_array {
    for (SomeObject *someObject in SomeObjects) {             
       [myArr addObject:someObject.someString];
       NSLog(@"Value: %@", [myArr objectAtIndex:([myArr count]-1)]); // works 
    }
  }
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      return [myArr count]; // works if I return const ("return 2")
  }
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      return 1;
  }
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      }
      cell.textLabel.text = [myArr objectAtIndex:indexPath.row]; //=@"ASDF" works.
      return cell;
  }
  </code></pre>