-2

I'm trying to debug my app, but when I run it through Xcode, I get a crash saying -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] This happens in cellForItemAtIndexPath: for the collection view, but it only happens when I'm debugging, if I install the app and run it without Xcode it works fine.

this is my code:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    FFSIncidentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 
    // Configure the cell 
    ...
}
Rob
  • 415,655
  • 72
  • 787
  • 1,044
SeanT
  • 1,741
  • 1
  • 16
  • 24
  • If you can't provide something that lets the problem be reproduced, there's nothing to say about it. You say your code behaves in this way. Prove it. – matt Jul 11 '16 at 00:16
  • maybe you can show your cellForItemAtIndexPath implementation? – Joshua Jul 11 '16 at 03:15
  • this is my code... - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { FFSIncidentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; // Configure the cell – SeanT Jul 11 '16 at 05:39
  • It breaks on that line, but I can't figure out why. It worked yesterday, I changed nothing, but today, crashola. – SeanT Jul 11 '16 at 05:41
  • When it "crashes", there's more to it than just a method name. There's generally a more complete description in the debug console and/or Xcode pauses execution, visually showing you not only where it stopped, but why. You can consider adding an [exception breakpoint](https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html). But, bottom line, there's not enough information in your question for us to diagnose the problem. – Rob Jul 11 '16 at 18:44

1 Answers1

0

So I figured this out, and hopefully this will help someone else. In my case, I have a UICollectionViewCell in a .Xib file. That cell has a UIScrollView and that UIScrollView has a UIView in it. The UIView is taller than the screen, so in IB I pulled it out of the scroll view so I could see it all, but I never moved it back to being a subview of the scroll view. Long story short, if you build a custom UITableViewCell or UICollectionViewCell, everything has to be a subview of the Cell, otherwise, CRASH!

SeanT
  • 1,741
  • 1
  • 16
  • 24