title: Custom Table View Cell
body: <p>I have created a custom UITableView Cell class for my UITableView. However, I cannot set the values within the cell for some reason. As in the values such as userName and userImage do not show when the table is loaded. This problem has been going for a few days. Below is my code, I used dummy values for sake of simplicity. If someone can please let me know what I am doing wrong, it would be appreciated. </p>
  
  <p>Thanks!</p>
  
  <p><strong>CODE</strong></p>
  
  <p><strong>CustomCell.h</strong></p>
  
  <pre><code>@interface CustomCell : UITableViewCell
  {
      IBOutlet UILabel *userName;
      IBOutlet UIImageView *userImage;
  }
  
  @property(strong,nonatomic) IBOutlet UILabel *userName;
  @property(strong,nonatomic) IBOutlet UIImageView *userImage;
  
  @end
  </code></pre>
  
  <p><strong>CustomCell.m</strong></p>
  
  <pre><code>#import "CustomCell.h"
  @interface CustomCell ()
  @end
  
  @implementation CustomCell
  @synthesize userName;
  @synthesize userImage;
  
    -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  {
      self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
      if (self) 
      {
          // Custom initialization
          NSArray *nibArray= [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
          self= [nibArray objectAtIndex:0];
      }
      return self;
  }
  
  -(void) setSelected:(BOOL)selected animated:(BOOL)animated
  {
      [super setSelected:selected animated:animated];
  }
  @end
  </code></pre>
  
  <p><strong>ViewController.m</strong> (The class with the UITableView that calls the custom cell)</p>
  
  <pre><code>-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
  {
  
      static NSString *CellIdentifier = @"CellIdentifier";
      CustomCell *cell=  [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if(cell == nil) 
      {
          cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
      cell.userName=@"Adam Scott";
      cell.userImage=[UIImage imageNamed:@"adam.png"];
      return cell;
  }
  </code></pre>