title: Assertion failure in UICollectionView _createPreparedCellForItem
body: <p><strong>EDIT</strong>: <em>for anyone having this problem, I've answered my question with a solution that worked for me, that you can find below.</em></p>
  
  <h2>Original Question</h2>
  
  <p>I'm trying to build a two-column, multi-section UICollectionView with two types of cells. There are two basic states (per section) I'm aiming for:  </p>
  
  <ul>
  <li><strong>There is at least one item to show</strong>
  
  <ul>
  <li>show at least one cell representing the item, where each cell has half the width of the entire CollectionView</li>
  </ul></li>
  <li><strong>There is no item to show</strong> 
  
  <ul>
  <li>show a special cell that represents the empty state which has a width of twice the normal cell (and thus it occupies the entire width of the CollectionView for that "row")</li>
  </ul></li>
  </ul>
  
  <p>I've constructed what I believe to be the correct setup for this, including overriding the <code>CollectionViewDelegateFlowLayout</code> method below:</p>
  
  <pre><code>- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      return [self trueSectionCount:indexPath.section] &gt; 0 ? CGSizeMake(kItemCellWidth, kItemCellHeight) : CGSizeMake(kItemCellEmptyWidth, kItemCellEmptyHeight);
  }
  </code></pre>
  
  <p>which returns an appropriate size matching some dimensions which are the same as the cells for both states.</p>
  
  <hr>
  
  <p><strong>My problem is as follows:</strong> After the first cell is created in the <code>cellForItemAtIndexPath:</code> method, and subsequently returned, an assertion failure is thrown, as follows:</p>
  
  <pre><code>*** Assertion failure in -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit_Sim/UIKit-2935.137/UICollectionView.m:1289
  </code></pre>
  
  <p>After reading <a href="https://stackoverflow.com/questions/19945873/uicollectionview-assertion-error-on-create-prepared-cell-for">some</a> / <a href="https://stackoverflow.com/questions/12599863/ios-assertion-failure-in-uicollectionview">other</a> / <a href="https://stackoverflow.com/questions/12611292/uicollectionview-assertion-failure">questions</a> on similar topics, I have some theories.  </p>
  
  <p>I previously thought it had to do with the fact that I'm using two different sizes, but that can't be right since I'm manually overriding the required method as I showed above, and I'm never setting the <code>itemSize</code> property of my <code>UICollectionViewFlowLayout</code> object. </p>
  
  <p>Another theory I had was that this may be caused by some funny business when registering my Nibs/Classes with the <code>UICollectionView</code>. Since I have two classes which could be used at any given time for item population, and from what I gathered from the comments in <code>UICollectionView.h</code>, specifically lines <code>102-104</code>, there should only be one registered class/nib associated with the view. So I commented out the registration of the nibs and instead of calling <code>dequeueReusableCellWithReuseIdentifier:</code> in <code>cellForItemAtIndexPath</code>, I simply initialize a new Cell to nil and then allow my logic to create the new cell from its appropriate nib, as opposed to allowing the <code>CollectionView</code> to attempt and dequeue or spawn a new cell using it's own internal logic (which I know Apple put in place recently which differentiates a <code>UICollectionView</code> from a <code>UITableView</code> in this regard). Unfortunately, I'm still getting this assertion failure. </p>
  
  <p>I've run out of ideas and I'd love to know if anyone can help me with this. Let me know if there is any more information I could have missed and I'll gladly provide it.</p>