title: Why is a cell valid but its elements are nil after creation
body: <p>This question applies to tableViews and to collectionViews.</p>
  
  <p>Lets talk about a collection view using a prototype cell.</p>
  
  <p>Suppose the prototype cell is assigned to <code>MyCollectionViewCell</code> class.</p>
  
  <p>Suppose that this class has two properties: <code>countryName</code> and <code>countryImage</code> (a label and a imageView, respectively).</p>
  
  <p>Why I cannot assign values for name and country during this method? and what is the best way to solve that?</p>
  
  <p>During this method...</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
    MyCollectionViewCell *cell = (MyCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
  
    NSArray *section = self.arrayData[indexPath.section];
  
    NSDictionary *itemOnSection = section[indexPath.row];
  
    // Configure the cell
    UIImage *image = [UIImage imageNamed:itemOnSection[@"image"]];
    NSString *name = itemOnSection[@"name"];
  
    cell.countryImage.image = image;
    cell.countryName.text = name;
  
    return cell;
  }
  </code></pre>
  
  <p>what will happen with this method is that cell will be a valid object but <code>cell.countryImage</code> and <code>cell.countryName</code> will be <code>nil</code>.</p>
  
  <p>what I don't understand is this: if the cell exists and is a valid object according to the debugger, why its elements are not initialized. What is the best way to solve that?</p>
  
  <p>this is MyCollectionViewCell.h</p>
  
  <pre><code>@interface MyCollectionViewCell : UICollectionViewCell
  
  @property (weak, nonatomic) IBOutlet UIImageView *countryImage;
  @property (weak, nonatomic) IBOutlet UILabel *countryName;
  
  
  @end
  </code></pre>
  
  <p>the outlets are connected to the elements on the prototype cell and the prototype cell has this class assigned.</p>
  
  <p>MyCollectionViewCell.m has nothing.</p>