title: UICollectionView insertItemAtIndexPath not working
body: <p>I am using a UICollectionView to produce a grid of cells say total of 10 i.e. 0-9.</p>
  
  <p>Now, I want to insert a new cell in the grid on click of one of the cells.</p>
  
  <p>so I have added the following line of code <code>[_collectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:10 inSection:0]]];</code>  inside the function <code>didSelectItemAtIndexPath</code>.</p>
  
  <p>So now, if I set <code>indexPathForItem:</code> as 10 (i.e. insert at last) then I get 'Assertion failure' error on this line. If I set `indexPathForItem:' anything between 0-9 then I get 'EXC_BAD_ACCESS...' error on this line.</p>
  
  <p>This is my complete code implementing UICollectionView:</p>
  
  <pre><code>- (void)loadView
  {
      self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  
  
      UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
      _collectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(0, 97.5,                                                     self.view.frame.size.width, self.view.frame.size.height-67.5) collectionViewLayout:layout];
      [_collectionView setDataSource:self];
      [_collectionView setDelegate:self];
  
      [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
      [_collectionView setBackgroundColor:[UIColor whiteColor]];
  
      [self.view addSubview:_collectionView];
  
  }
  
  - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:    (NSInteger)section
  {
      return 35;
  }
  
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
  
      cell.layer.borderWidth=.5f;
      cell.layer.borderColor=[UIColor blackColor].CGColor;
  
      if(indexPath.item&lt;31)
      {
          _dayNumber = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 15, 15)];
          _dayNumber.font = [UIFont systemFontOfSize:12];
          _dayNumber.text = [NSString stringWithFormat:@"%ld",(indexPath.item + 1)];
          [cell addSubview:_dayNumber];
      }
  
  
      return cell;
  }   
  
  - (CGSize)collectionView:(UICollectionView *)collectionView layout:    (UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      return CGSizeMake(self.view.frame.size.width/7, self.view.frame.size.width/7);
  }
  
  - (CGFloat)collectionView:(UICollectionView *)collectionView layout:    (UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:    (NSInteger)section
  {
      return 0.0;
  }
  
  - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  {
      return 0.0;
  }
  
  // Layout: Set Edges
  - (UIEdgeInsets)collectionView:
  (UICollectionView *)collectionView layout:    (UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  {
      return UIEdgeInsetsMake(0,0,0,0);  // top, left, bottom, right
  }
  
  - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:    (NSIndexPath *)indexPath
  {
      [_collectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:0 inSection:0]]];
  }
  </code></pre>
  
  <p>Any help?</p>