NSInvalidArgumentException with UICollectionView

Hello, i just moved to XCode 8 and Swift 3

I've made all the corrections i have to do in order to get the App going, but when i'm running the app it crashes giving me a:

2016-11-08 15:00:18.740 Diez[64477:6453746] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.

And This StackTrace:

2016-11-08 15:00:23.648 Diez[64477:6453746] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Diez.HomeSeccionesViewController collectionView:cellForItemAtIndexPath:]: unrecognized selector sent to instance 0x7fec1d647900'
*** First throw call stack:
(
  0   CoreFoundation                      0x000000010583534b __exceptionPreprocess + 171
  1   libobjc.A.dylib                     0x000000010529621e objc_exception_throw + 48
  2   CoreFoundation                      0x00000001058a4f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
  3   CoreFoundation                      0x00000001057bac15 ___forwarding___ + 1013
  4   CoreFoundation                      0x00000001057ba798 _CF_forwarding_prep_0 + 120
  5   UIKit                               0x0000000107bc3980 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 467
  6   UIKit                               0x0000000107bc37a7 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
  7   UIKit                               0x0000000107bc8c7f -[UICollectionView _updateVisibleCellsNow:] + 4803
  8   UIKit                               0x0000000107bce913 -[UICollectionView layoutSubviews] + 313
  9   UIKit                               0x0000000107345f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
  10  QuartzCore                          0x00000001070f8cc4 -[CALayer layoutSublayers] + 146
  11  QuartzCore                          0x00000001070ec788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
  12  UIKit                               0x0000000107333ff0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1507
  13  UIKit                               0x000000010746369d -[UINavigationController _layoutViewController:] + 1625
  14  UIKit                               0x00000001074624cb -[UINavigationController _layoutTopViewController] + 341
  15  UIKit                               0x000000010745f811 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 921
  16  UIKit                               0x000000010774d974 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 418
  17  UIKit                               0x000000010774dcd6 -[UINavigationTransitionView _cleanupTransition] + 766
  18  UIKit                               0x000000010730e475 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 222
  19  UIKit                               0x0000000107309f6e +[UIViewAnimationState popAnimationState] + 307
  20  UIKit                               0x000000010774d6ea -[UINavigationTransitionView transition:fromView:toView:] + 2808
  21  UIKit                               0x0000000107464747 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3314
  22  UIKit                               0x0000000107464ce5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
  23  UIKit                               0x0000000107465dc7 -[UINavigationController __viewWillLayoutSubviews] + 58
  24  UIKit                               0x000000010765cd6f -[UILayoutContainerView layoutSubviews] + 223
  25  UIKit                               0x0000000107345f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
  26  QuartzCore                          0x00000001070f8cc4 -[CALayer layoutSublayers] + 146
  27  QuartzCore                          0x00000001070ec788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
  28  QuartzCore                          0x00000001070ec606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
  29  QuartzCore                          0x000000010707a680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
  30  QuartzCore                          0x00000001070a7767 _ZN2CA11Transaction6commitEv + 475
  31  UIKit                               0x00000001072ac484 _afterCACommitHandler + 346
  32  CoreFoundation                      0x00000001057d9e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
  33  CoreFoundation                      0x00000001057d9d87 __CFRunLoopDoObservers + 391
  34  CoreFoundation                      0x00000001057beb9e __CFRunLoopRun + 1198
  35  CoreFoundation                      0x00000001057be494 CFRunLoopRunSpecific + 420
  36  GraphicsServices                    0x000000010ae03a6f GSEventRunModal + 161
  37  UIKit                               0x0000000107281964 UIApplicationMain + 159
  38  Diez                                0x000000010402f0bf main + 111
  39  libdyld.dylib                       0x00000001099cc68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Any Help

Thanks

Erick

Replies

-[Diez.HomeSeccionesViewController collectionView:cellForItemAtIndexPath:]

This indicates that the collection view tried to call the

-collectionView:cellForItemAtIndexPath:
method on your HomeSeccionesViewController class and it’s not implemented. Are you expecting that class to implement that method? If so, you should double check that you have the method signature correct in Swift.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"