Libc abi.dylib: termination with an uncaught exception of type NSException CollectionView

when i run my application i got this error:

2014-08-11 10: 52: 10.546 ControlViewTest [918: 60b] - [UIViewController collectionView: numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0
2014-08-11 10: 52: 10.605 ControlViewTest [918: 60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UIViewController collectionView: numberOfItemsInSection:]: unrecognized selector sent to instance 0x8c862f0'
* First throw call stack:
(
    0 CoreFoundation 0x017ec1e4 exceptionPreprocess + 180
    1 libobjc.A.dylib 0x0156b8e5 objc_exception_throw + 44
    2 CoreFoundation 0x01889243 - [NSObject (NSObject) doesNotRecognizeSelector:] + 275
    3 CoreFoundation 0x017dc50b ___forwarding_ + 1019
    4 CoreFoundation 0x017dc0ee _CF_forwarding_prep_0 + 14
    5 UIKit 0x008b0c34 - [UICollectionViewData _updateItemCounts] + 331
    6 UIKit 0x008b0ce1 - [UICollectionViewData _validateItemCounts] + 45
    7 UIKit 0x008b2c64 - [UICollectionViewData numberOfSections] + 35
    8 UIKit 0x0087d6ed - [UICollectionView numberOfSections] + 62
    9 UIKit 0x0089d614 - [UICollectionViewFlowLayout (Internal) _getSizingInfos] + 205
    10 UIKit 0x0089e48f - [UICollectionViewFlowLayout (Internal) _fetchItemsInfo] + 521
    11 UIKit 0x00899fe2 - [UICollectionViewFlowLayout prepareLayout] + 157
    12 UIKit 0x008b0d9d - [UICollectionViewData _prepareToLoadData] + 76
    13 UIKit 0x008b15c5 - [UICollectionViewData validateLayoutInRect:] + 56
    14 UIKit 0x00877603 - [UICollectionView layoutSubviews] + 173
    15 UIKit 0x0029a964 - [UIView (CALayerDelegate) layoutSublayersOfLayer:] + 355
    16 libobjc.A.dylib 0x0157d82b - [NSObject performSelector: withObject:] + 70
    17 QuartzCore 0x03c5745a - [CALayer layoutSublayers] + 148
    18 QuartzCore 0x03c4b244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    19 QuartzCore 0x03c573a5 - [CALayer layoutIfNeeded] + 160
    20 UIKit 0x0035cae3 - [UIViewController window: setupWithInterfaceOrientation:] + 304
    21 UIKit 0x00272aa7 - [UIWindow _setRotatableClient: toOrientation: updateStatusBar: duration: force: isRotating:] + 5212
    22 UIKit 0x00271646 - [UIWindow _setRotatableClient: toOrientation: updateStatusBar: duration: force:] + 82
    23 UIKit 0x00271518 - [UIWindow _setRotatableViewOrientation: updateStatusBar: duration: force:] + 117
    24 UIKit 0x002715a0 - [UIWindow _setRotatableViewOrientation: duration: force:] + 67
    25 UIKit 0x0027063a 57- [UIWindow _updateToInterfaceOrientation: duration: force:] _ block_invoke + 120
    26 UIKit 0x0027059c - [UIWindow _updateToInterfaceOrientation: duration: force:] + 400
    27 UIKit 0x002712f3 - [UIWindow setAutorotates: forceUpdateInterfaceOrientation:] + 870
    28 UIKit 0x002748e6 - [UIWindow setDelegate:] + 449
    29 UIKit 0x0034eb77 - [UIViewController _tryBecomeRootViewControllerInWindow:] + 180
    30 UIKit 0x0026a474 - [UIWindow addRootViewControllerViewIfPossible] + 591
    31 UIKit 0x0026a5ef - [UIWindow _setHidden: forced:] + 312
    32  UIKit                               0x0026a86b -[UIWindow _orderFrontWithoutMakingKey] + 49
    33  UIKit                               0x002753c8 -[UIWindow makeKeyAndVisible] + 65
    34  UIKit                               0x00225bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
    35  UIKit                               0x0022a667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    36  UIKit                               0x0023ef92 -[UIApplication handleEvent:withNewEvent:] + 3517
    37  UIKit                               0x0023f555 -[UIApplication sendEvent:] + 85
    38  UIKit                               0x0022c250 _UIApplicationHandleEvent + 683
    39  GraphicsServices                    0x037e1f02 _PurpleEventCallback + 776
    40 GraphicsServices 0x037e1a0d PurpleEventCallback + 46
    41 CoreFoundation 0x01767ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 53
    42 CoreFoundation 0x017679db __CFRunLoopDoSource1 + 523
    43 CoreFoundation 0x0179268c __CFRunLoopRun + 2156
    44 CoreFoundation 0x017919d3 CFRunLoopRunSpecific + 467
    45 CoreFoundation 0x017917eb CFRunLoopRunInMode + 123
    46 UIKit 0x00229d9c - [UIApplication _run] + 840
    47 UIKit 0x0022bf9b UIApplicationMain + 1225
    48 ControlViewTest 0x0000264d main + 141
    49 libdyld.dylib 0x01e33701 start + 1
)
libc ++ abi.dylib: terminating with uncaught exception of type NSException
(lldb)

someone can help me pls
+4
source share
1 answer

Yours UICollectionViewhas a set of data sources that does not implement the required method collectionView:numberOfItemsInSection:. You need to assign a UICollectionViewvalid data source: the class that you wrote and that implements collectionView:numberOfItemsInSection:.

+6
source

All Articles