UIAlertView show crash - ios

I make an UIAleartView show information when first init:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#""
message:#"..."
delegate:self
cancelButtonTitle:#"..."
otherButtonTitles:#"...", nil];
alertView.tag = 1;
[alertView show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch (alertView.tag) {
case 1: {
[UICKeyChainStore setString:#"YES" forKey:kDebutFirstMsgShow];
if (buttonIndex == 0) {
NSNotificationCenter *noti = [NSNotificationCenter defaultCenter];
[noti postNotificationName:#"...." object:nil];
}
break;
}
default:
break;
}
}
And here is log:
2017-02-10 01:16:44.206 audition[1740:55532] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b09bd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010aad421e objc_exception_throw + 48
2 CoreFoundation 0x000000010afcd2eb -[__NSArrayM objectAtIndex:] + 203
3 UIKit 0x0000000109854e8f __86-[_UIAlertControllerView _unlocalizedOrderedPresentableAlertActionViewRepresentations]_block_invoke + 68
4 CoreFoundation 0x000000010b02b0b2 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
5 CoreFoundation 0x000000010b02af42 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 194
6 UIKit 0x0000000109854dfc -[_UIAlertControllerView _unlocalizedOrderedPresentableAlertActionViewRepresentations] + 213
7 UIKit 0x00000001098543b5 -[_UIAlertControllerView _reloadInterfaceActionViewRepresentations] + 50
8 UIKit 0x0000000109855f6e -[_UIAlertControllerView _setVisualStyle:] + 380
9 UIKit 0x00000001090bab35 -[UIAlertController _updateProvidedStyleWithTraitCollection:] + 455
10 UIKit 0x00000001090bac0f -[UIAlertController _updateProvidedStyle] + 57
11 UIKit 0x00000001090bae7a -[UIAlertController traitCollectionDidChange:] + 236
12 UIKit 0x0000000108eedfac -[UIViewController _traitCollectionDidChange:] + 108
13 UIKit 0x0000000108eee0cf -[UIViewController _updateTraitsIfNecessary] + 269
14 UIKit 0x0000000108e12957 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 884
15 QuartzCore 0x000000010bb2abf8 -[CALayer layoutSublayers] + 146
16 QuartzCore 0x000000010bb1e440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
17 UIKit 0x0000000108e00928 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1509
18 UIKit 0x0000000108df6e33 -[UIView(Geometry) setBounds:] + 2387
19 UIKit 0x0000000108df603d -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 608
20 UIKit 0x0000000108e0080e -[UIView(Hierarchy) layoutBelowIfNeeded] + 1227
21 UIKit 0x0000000108df315b -[UIView(Geometry) setFrame:] + 1297
22 UIKit 0x00000001090b9f26 -[UIAlertController loadView] + 201
23 UIKit 0x0000000108eef61c -[UIViewController loadViewIfRequired] + 201
24 UIKit 0x0000000108eefe70 -[UIViewController view] + 27
25 UIKit 0x0000000108f0a0a5 -[UIViewController _setPresentationController:] + 100
26 UIKit 0x0000000108f015f4 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1355
27 UIKit 0x0000000108f0328e -[UIViewController _presentViewController:withAnimationController:completion:] + 4971
28 UIKit 0x0000000108f0626b -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 530
29 UIKit 0x0000000108f05d51 -[UIViewController presentViewController:animated:completion:] + 179
30 UIKit 0x00000001098413bf -[_UIAlertControllerShimPresenterWindow presentAlertController:animated:completionBlock:] + 642
31 UIKit 0x000000010983f6f6 -[_UIAlertControllerShimPresenter _presentAlertControllerAnimated:completion:] + 219
32 UIKit 0x00000001090d42e6 -[UIAlertView _showAnimated:] + 278
33 audition 0x00000001063f9840 -[DebutVC viewWillAppear:] + 448
34 UIKit 0x0000000108ef596f -[UIViewController _setViewAppearState:isAnimating:] + 692
35 UIKit 0x0000000108ef607f -[UIViewController __viewWillAppear:] + 147
36 UIKit 0x0000000108e0b59b __86+[UIView(Internal) _transitionFromView:toView:duration:options:animations:completion:]_block_invoke + 62
37 UIKit 0x0000000108e085c0 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 581
38 UIKit 0x0000000108e087f2 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:animations:start:completion:] + 145
39 UIKit 0x0000000108e0b4bf +[UIView(Internal) _transitionFromView:toView:duration:options:animations:completion:] + 603
40 UIKit 0x0000000108f1677a -[UIViewController(UIContainerViewControllerProtectedMethods) transitionFromViewController:toViewController:duration:options:animations:completion:] + 771
41 audition 0x000000010645c1b1 -[MHTabBarController setSelectedIndex:animated:] + 2849
42 audition 0x000000010645cca3 -[MHTabBarController tabButtonPressed:] + 99
43 UIKit 0x0000000108d4f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
44 UIKit 0x0000000108ed5c38 -[UIControl sendAction:to:forEvent:] + 67
45 UIKit 0x0000000108ed5f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
46 UIKit 0x0000000108ed4910 -[UIControl touchesBegan:withEvent:] + 304
47 UIKit 0x0000000108dbd285 -[UIWindow _sendTouchesForEvent:] + 2043
48 UIKit 0x0000000108dbec33 -[UIWindow sendEvent:] + 4011
49 UIKit 0x0000000108d6b9ab -[UIApplication sendEvent:] + 371
50 UIKit 0x000000010955872d __dispatchPreprocessedEventFromEventQueue + 3248
51 UIKit 0x0000000109551463 __handleEventQueue + 4879
52 CoreFoundation 0x000000010b040761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
53 CoreFoundation 0x000000010b02598c __CFRunLoopDoSources0 + 556
54 CoreFoundation 0x000000010b024e76 __CFRunLoopRun + 918
55 CoreFoundation 0x000000010b024884 CFRunLoopRunSpecific + 420
56 GraphicsServices 0x000000010ca64a6f GSEventRunModal + 161
57 UIKit 0x0000000108d4dc68 UIApplicationMain + 159
58 audition 0x0000000106493c91 main + 241
59 libdyld.dylib 0x000000010d05868d start + 1
From the log file NSRangeException there is an array empty but i access to element 0 of it. But
Crash disappear when i comment [alertview show];
What is reason of this crash ?

The crash log shows that your code is happening here:
33 audition 0x00000001063f9840 -[DebutVC viewWillAppear:] + 448
You can't show an alert from viewWillAppear, because your view is not in the interface yet (it will appear, but it has not yet done so). Try moving your show code to viewDidAppear instead.

Related

migrated project from xcode 8 to xcode 9 crash on launcher screen

Everything was working fine on xcode 7.3.1, Than I have to add braintree 3ds sdk which is supported on xcode 8. So, I migrated the code to xcode 8 and than xcode 9. Now, build working fine on below IOS 11 but on ios 11 and above app is crashing before opening new main screen. I am new to Ios please help.
it's crashing on this line :
let vc = storyboard?.instantiateViewController(withIdentifier: "KbNav") as! KabNavigationController
2018-08-30 12:25:52.730641+0500 Kab[2970:32711] *** Assertion failure in
-[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-
3698.33.6/_UINavigationBarVisualProviderModernIOS.m:569
2018-08-30 12:25:52.769549+0500 Kab[2970:32711] *** Terminating app due
to uncaught exception 'NSInternalInconsistencyException', reason: 'Sigh.
Contentview size is zero.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000115da712b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000114d50f41 objc_exception_throw + 48
2 CoreFoundation 0x0000000115dac2f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001147f1d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x00000001131382f5 -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight] + 265
5 UIKit 0x0000000112eb65e0 -[UINavigationItem _desiredHeightForBarMetrics:defaultHeightBlock:] + 90
6 UIKit 0x000000011313afa1 -[_UINavigationBarVisualProviderModernIOS heightRangeFittingWidth:] + 412
7 UIKit 0x000000011264a0ed -[UINavigationBar _heightRangeForNavigationItem:fittingWidth:] + 210
8 UIKit 0x0000000112726a98 -[UINavigationController _intrinsicNavigationBarHeightRangeForViewController:] + 187
9 UIKit 0x00000001127269b6 -[UINavigationController _preferredHeightForHidingNavigationBarForViewController:] + 628
10 UIKit 0x000000011271688f -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 356
11 UIKit 0x0000000112716cf8 -[UINavigationController _positionNavigationBarHidden:edge:] + 388
12 UIKit 0x000000011271e555 -[UINavigationController loadView] + 243
13 UIKit 0x00000001126e105c -[UIViewController loadViewIfRequired] + 195
14 UIKit 0x00000001126e18b9 -[UIViewController view] + 27
15 Kab 0x000000010f00faea -[SlideNavigationController setEnableShadow:] + 74
16 Kab 0x000000010f00d494 -[SlideNavigationController setup] + 244
17 Kab 0x000000010f00d1d1 -[SlideNavigationController initWithCoder:] + 145
18 Kab 0x000000010f20e1d6 _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfc + 214
19 Kab 0x000000010f20e29f _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
20 UIKit 0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
21 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
22 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
23 UIKit 0x000000011264675a -[UINavigationBar initWithCoder:] + 753
24 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
25 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
26 UIKit 0x0000000112eb15f2 -[UINavigationItem initWithCoder:] + 1018
27 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
28 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
29 UIKit 0x00000001126dc053 -[UIViewController initWithCoder:] + 432
30 Kab 0x000000010f29a6a8 _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfc + 7704
31 Kab 0x000000010f29a77f _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
32 UIKit 0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
33 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
34 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
35 UIKit 0x00000001129ca194 -[UIRuntimeConnection initWithCoder:] + 178
36 UIKit 0x00000001129ca8d0 -[UIRuntimeEventConnection initWithCoder:] + 59
37 UIKit 0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
38 UIKit 0x0000000112c1f2a7 UINibDecoderDecodeObjectForValue + 1118
39 UIKit 0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
40 UIKit 0x00000001129c9391 -[UINib instantiateWithOwner:options:] + 1262
41 UIKit 0x0000000112e59fc2 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
42 Kab 0x000000010f135a7b _T08Kabr24LaunchTourViewControllerC4skipyyXlF + 219
43 Kab 0x000000010f136118 _T08Kab24LaunchTourViewControllerC4skipyyXlFTo + 56
44 UIKit 0x000000011253a972 -[UIApplication sendAction:to:from:forEvent:] + 83
45 UIKit 0x00000001126b9c3c -[UIControl sendAction:to:forEvent:] + 67
46 UIKit 0x00000001126b9f59 -[UIControl _sendActionsForEvents:withEvent:] + 450
47 UIKit 0x00000001126b8e86 -[UIControl touchesEnded:withEvent:] + 618
48 UIKit 0x00000001125b0807 -[UIWindow _sendTouchesForEvent:] + 2807
49 UIKit 0x00000001125b1f2a -[UIWindow sendEvent:] + 4124
50 UIKit 0x0000000112555365 -[UIApplication sendEvent:] + 352
51 UIKit 0x0000000112ea1a1d __dispatchPreprocessedEventFromEventQueue + 2809
52 UIKit 0x0000000112ea4672 __handleEventQueueInternal + 5957
53 CoreFoundation 0x0000000115d4a101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
54 CoreFoundation 0x0000000115de9f71 __CFRunLoopDoSource0 + 81
55 CoreFoundation 0x0000000115d2ea19 __CFRunLoopDoSources0 + 185
56 CoreFoundation 0x0000000115d2dfff __CFRunLoopRun + 1279
57 CoreFoundation 0x0000000115d2d889 CFRunLoopRunSpecific + 409
58 GraphicsServices 0x0000000118d049c6 GSEventRunModal + 62
59 UIKit 0x00000001125395d6 UIApplicationMain + 159
60 Kab 0x000000010f191137 main + 55
61 libdyld.dylib 0x0000000117112d81 start + 1
62 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
KbNavigationController
class KabNavigationController: SlideNavigationController {
var menuItems: [(id: String, image: String, text: String)] = []
override func viewDidLoad() {
self.leftMenu = self.storyboard?.instantiateViewController(withIdentifier: "MenuViewController")
navigationBar.barTintColor = Theme.DarkGray
navigationBar.tintColor = Theme.White
navigationBar.barStyle = UIBarStyle.black
// Popup Navigation Bar
STPopupNavigationBar.appearance().isHidden = true
}
}
I have searched and debug my code alot keep in mind always enable exception break points to trigger exactly which line causing the crash. You can learn it from this Exception Breakpoint in Xcode . I found my solution here https://github.com/aryaxt/iOS-Slide-Menu/issues/250.
move these two lines from setup function to viewWillLayoutSubviews of Slide Menu.
//moved this from the `setup` function:
self.enableShadow = YES;
self.enableSwipeGesture = YES;

App is crashing on adding #IBAction in view controller

I was trying to add a tool bar at the bottom of UITableView which is> successfully added. But when i connect the bar button with IBAction,
on loading of that view controller app just crashes. Without linking
to IbAction app works fine.
I am using xCode 9.2
Here is my storyboard.
Here is the crash log.
2018-04-11 11:11:38.636121+0500 SafeBolt[9610:88848] *** Assertion failure in -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/_UINavigationBarVisualProviderModernIOS.m:569
2018-04-11 11:11:38.662356+0500 SafeBolt[9610:88848] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Sigh. Contentview size is zero.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001072b612b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001063fdf41 objc_exception_throw + 48
2 CoreFoundation 0x00000001072bb2f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000105e9ed69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x00000001085d22f5 -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight] + 265
5 UIKit 0x00000001083505e0 -[UINavigationItem _desiredHeightForBarMetrics:defaultHeightBlock:] + 90
6 UIKit 0x00000001085d4fa1 -[_UINavigationBarVisualProviderModernIOS heightRangeFittingWidth:] + 412
7 UIKit 0x0000000107ae40ed -[UINavigationBar _heightRangeForNavigationItem:fittingWidth:] + 210
8 UIKit 0x0000000107bc0a98 -[UINavigationController _intrinsicNavigationBarHeightRangeForViewController:] + 187
9 UIKit 0x0000000107bc09b6 -[UINavigationController _preferredHeightForHidingNavigationBarForViewController:] + 628
10 UIKit 0x0000000107bb088f -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 356
11 UIKit 0x0000000107bb0cf8 -[UINavigationController _positionNavigationBarHidden:edge:] + 388
12 UIKit 0x0000000107bb8555 -[UINavigationController loadView] + 243
13 UIKit 0x0000000107b7b05c -[UIViewController loadViewIfRequired] + 195
14 UIKit 0x0000000107b7b8b9 -[UIViewController view] + 27
15 iOS_Slide_Menu 0x00000001054bbe5a -[SlideNavigationController setEnableShadow:] + 74
16 iOS_Slide_Menu 0x00000001054b9804 -[SlideNavigationController setup] + 244
17 iOS_Slide_Menu 0x00000001054b9541 -[SlideNavigationController initWithCoder:] + 145
18 UIKit 0x0000000107e644c8 -[UIClassSwapper initWithCoder:] + 246
19 UIKit 0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
20 UIKit 0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
21 UIKit 0x0000000107ae075a -[UINavigationBar initWithCoder:] + 753
22 UIKit 0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
23 UIKit 0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
24 UIKit 0x000000010834b5f2 -[UINavigationItem initWithCoder:] + 1018
25 UIKit 0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
26 UIKit 0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
27 UIKit 0x0000000107b76053 -[UIViewController initWithCoder:] + 432
28 SafeBolt 0x000000010448dfa2 _T08SafeBolt18BaseViewControllerCACSgSo7NSCoderC5coder_tcfc + 66
29 SafeBolt 0x000000010446db83 _T08SafeBolt26EmailListingViewControllerCACSgSo7NSCoderC5coder_tcfc + 1315
30 SafeBolt 0x000000010446dc4f _T08SafeBolt26EmailListingViewControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
31 UIKit 0x0000000107e644c8 -[UIClassSwapper initWithCoder:] + 246
32 UIKit 0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
33 UIKit 0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
34 UIKit 0x0000000107e64194 -[UIRuntimeConnection initWithCoder:] + 178
35 UIKit 0x0000000107e648d0 -[UIRuntimeEventConnection initWithCoder:] + 59
36 UIKit 0x00000001080b9109 UINibDecoderDecodeObjectForValue + 704
37 UIKit 0x00000001080b92a7 UINibDecoderDecodeObjectForValue + 1118
38 UIKit 0x00000001080b8e3e -[UINibDecoder decodeObjectForKey:] + 89
39 UIKit 0x0000000107e63391 -[UINib instantiateWithOwner:options:] + 1262
40 UIKit 0x00000001082f3fc2 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
41 SafeBolt 0x000000010448eda2 _T08SafeBolt11AppDelegateC23setUpRootViewControlleryyF + 386
42 SafeBolt 0x000000010448f6b5 _T08SafeBolt11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tF + 101
43 SafeBolt 0x000000010448f79a _T08SafeBolt11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFTo + 186
44 UIKit 0x00000001079cabca -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
45 UIKit 0x00000001079cc648 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4113
46 UIKit 0x00000001079d1aeb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1720
47 UIKit 0x0000000107d9b6f8 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 924
48 UIKit 0x00000001081714c8 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
49 UIKit 0x0000000107d9b2f1 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 249
50 UIKit 0x0000000107d9bb6b -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 696
51 UIKit 0x0000000108719a69 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 262
52 UIKit 0x0000000108719922 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 444
53 UIKit 0x00000001083f69c8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
54 UIKit 0x00000001085f5b06 _performActionsWithDelayForTransitionContext + 100
55 UIKit 0x00000001083f688b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 231
56 UIKit 0x0000000108170b25 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
57 UIKit 0x00000001079d036a -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 523
58 UIKit 0x0000000107fab605 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 369
59 FrontBoardServices 0x000000010d340cc0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 338
60 FrontBoardServices 0x000000010d3497b5 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 235
61 libdispatch.dylib 0x000000010af5933d _dispatch_client_callout + 8
62 libdispatch.dylib 0x000000010af5e9f3 _dispatch_block_invoke_direct + 592
63 FrontBoardServices 0x000000010d375498 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
64 FrontBoardServices 0x000000010d37514e -[FBSSerialQueue _performNext] + 464
65 FrontBoardServices 0x000000010d3756bd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
66 CoreFoundation 0x0000000107259101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
67 CoreFoundation 0x00000001072f8f71 __CFRunLoopDoSource0 + 81
68 CoreFoundation 0x000000010723da19 __CFRunLoopDoSources0 + 185
69 CoreFoundation 0x000000010723cfff __CFRunLoopRun + 1279
70 CoreFoundation 0x000000010723c889 CFRunLoopRunSpecific + 409
71 GraphicsServices 0x000000010dcb79c6 GSEventRunModal + 62
72 UIKit 0x00000001079d35d6 UIApplicationMain + 159
73 SafeBolt 0x0000000104490d27 main + 55
74 libdyld.dylib 0x000000010afd5d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is the code for IbAction.
#IBAction func testAction(_ sender: UIBarButtonItem) {
}
Any help would be appreciated.
Please try the following steps in order to solve this issue. Also let me know if it doesn't work for you.
Select the item in storyboard for which you are trying to add IBAction
Check in the connection inspector and see if there are still some extra connections other then the required one.
If there are other extra connections delete them and compile your code again. It should work.
This error usually happens when you create connections and deletes the code from your controller but your connection still exists.

QLPreviewController crash on share iOS 9

I use QLPreviewController to preview images and pdf files. It works perfectly for iOS7-9. However, when I tap share button on device with iOS9, app crashes immediately with following exception:
Fatal Exception: NSInvalidArgumentException *** -[__NSCFString rangeOfString:options:range:locale:]: nil argument
This doesn't happen on simulator with iOS9. I am able to see AirDrop sharing menu on devices with iOS7&8, but strange (null) title appears on the top of description. Here is link to sample screenshot, taken on iPhone 5 with iOS7:
Have any of you experienced such issue?
Full stacktrace from CrashLytics
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x00000001860a0f5c __exceptionPreprocess + 124
1 libobjc.A.dylib 0x000000019ac97f80 objc_exception_throw + 56
2 CoreFoundation 0x00000001860a0ea4 -[NSException initWithCoder:]
3 Foundation 0x0000000186efe598 -[NSString rangeOfString:options:range:locale:] + 348
4 Sharing 0x0000000195064118 -[SFAirDropActivityViewController attributedStringWithTitle:content:]
5 Sharing 0x00000001950633e0 -[SFAirDropActivityViewController viewDidLoad]
6 UIKit 0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
7 UIKit 0x000000018b5f7194 -[UIViewController view] + 28
8 UIKit 0x000000018bf3a244 __79-[_UIActivityGroupListViewController updateVisibleActivityGroupViewControllers]_block_invoke115 + 112
9 CoreFoundation 0x0000000185f9e6f0 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 100
10 CoreFoundation 0x0000000185f95418 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 148
11 UIKit 0x000000018bf39e90 -[_UIActivityGroupListViewController updateVisibleActivityGroupViewControllers] + 456
12 UIKit 0x000000018bf3a754 -[_UIActivityGroupListViewController viewDidLoad] + 720
13 UIKit 0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
14 UIKit 0x000000018b5f7194 -[UIViewController view] + 28
15 UIKit 0x000000018ba4901c -[UIAlertController setContentViewController:] + 284
16 UIKit 0x000000018b7f0278 -[UIActivityViewController viewDidLoad] + 1280
17 UIKit 0x000000018b5f7610 -[UIViewController loadViewIfRequired] + 1124
18 UIKit 0x000000018b5f7194 -[UIViewController view] + 28
19 UIKit 0x000000018b969bfc -[UIViewController _setPresentationController:] + 108
20 UIKit 0x000000018b962e58 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1328
21 UIKit 0x000000018b964840 -[UIViewController _presentViewController:withAnimationController:completion:] + 4428
22 UIKit 0x000000018b967278 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 472
23 UIKit 0x000000018b6ee0a4 -[UIViewController presentViewController:animated:completion:] + 184
24 UIKit 0x000000018bc48c84 _UIDocumentInteractionControllerPresentPopoverFromItemOrShowActivityViewController + 356
25 UIKit 0x000000018bc48a70 -[UIDocumentInteractionController presentOptionsMenuFromBarButtonItem:animated:] + 264
26 QuickLook 0x000000018af9d220 -[QLPreviewController actionButtonTapped:] + 220
27 UIKit 0x000000018b62e3c8 -[UIApplication sendAction:to:from:forEvent:] + 100
28 UIKit 0x000000018b7ad3dc -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 168
29 UIKit 0x000000018b62e3c8 -[UIApplication sendAction:to:from:forEvent:] + 100
30 UIKit 0x000000018b62e344 -[UIControl sendAction:to:forEvent:] + 80
31 UIKit 0x000000018b616c6c -[UIControl _sendActionsForEvents:withEvent:] + 416
32 UIKit 0x000000018b616db8 -[UIControl _sendActionsForEvents:withEvent:] + 748
33 UIKit 0x000000018b62dc5c -[UIControl touchesEnded:withEvent:] + 572
34 UIKit 0x000000018b62d88c -[UIWindow _sendTouchesForEvent:] + 804
35 UIKit 0x000000018b626ac0 -[UIWindow sendEvent:] + 784
36 UIKit 0x000000018b5f7a10 -[UIApplication sendEvent:] + 248
37 UIKit 0x000000018b5f5efc _UIApplicationHandleEventQueue + 5348
38 CoreFoundation 0x00000001860585a4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
39 CoreFoundation 0x0000000186058038 __CFRunLoopDoSources0 + 540
40 CoreFoundation 0x0000000186055d38 __CFRunLoopRun + 724
41 CoreFoundation 0x0000000185f84dc0 CFRunLoopRunSpecific + 384
42 GraphicsServices 0x00000001910d8088 GSEventRunModal + 180
43 UIKit 0x000000018b65ef44 UIApplicationMain + 204
I met the same problem.
My solution is,Do something to SFAirDropActivityViewController.
the code:
#interface SFAirDropActivityViewController : UIViewController
+ (BOOL)isAirDropAvailable;
#end
#implementation SFAirDropActivityViewController
+ (BOOL)isAirDropAvailable{
return NO;
}
#end
PrivateFrameworks address:
https://github.com/nst/iOS-Runtime-Headers/blob/master/PrivateFrameworks/Sharing.framework/SFAirDropActivityViewController.h

libc abi.dylib: terminating with uncaught exception of type NSException CollectionView

when i run my app, i received 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)
somebody can help me pls
Your UICollectionView has a data source set which does not implement the required method collectionView:numberOfItemsInSection:. You need to assign your UICollectionView a valid data source: a class that you've written and that implements collectionView:numberOfItemsInSection:.

I got this issue "Terminating with uncaught exception of type NSException" with my execution, can anybody help me with this?

Can I get helped with the below issue? I'm struck over here. While executing the code I'm getting this log. I couldn't find the solution for it. I tried it for the whole day but couldn't find the solution for it.
2014-05-29 10:34:35.723 Timesheet[14438:60b] -[UITableViewCell setAlternateRowColor:]: unrecognized selector sent to instance 0x8f98a70
2014-05-29 10:34:35.764 Timesheet[14438:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setAlternateRowColor:]: unrecognized selector sent to instance 0x8f98a70'
*** First throw call stack:
(
0 CoreFoundation 0x0180a1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015898e5 objc_exception_throw + 44
2 CoreFoundation 0x018a7243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x017fa50b ___forwarding___ + 1019
4 CoreFoundation 0x017fa0ee _CF_forwarding_prep_0 + 14
5 Timesheet 0x00002e13 -[ViewController tableView:cellForRowAtIndexPath:] + 691
6 UIKit 0x0034211f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
7 UIKit 0x003421f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
8 UIKit 0x00323ece -[UITableView _updateVisibleCellsNow:] + 2428
9 UIKit 0x003386a5 -[UITableView layoutSubviews] + 213
10 UIKit 0x002b8964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
11 libobjc.A.dylib 0x0159b82b -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x03c7545a -[CALayer layoutSublayers] + 148
13 QuartzCore 0x03c69244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x03c77885 -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 43
15 UIKit 0x002ab026 -[UIView(Hierarchy) layoutBelowIfNeeded] + 595
16 UIKit 0x002aadcd -[UIView(Hierarchy) layoutIfNeeded] + 74
17 UIKit 0x0038e744 -[UINavigationController _layoutViewController:] + 1062
18 UIKit 0x0038d966 -[UINavigationController _layoutTopViewController] + 176
19 UIKit 0x0038bb95 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 429
20 UIKit 0x0058f74e -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 328
21 UIKit 0x0058fa53 -[UINavigationTransitionView _cleanupTransition] + 703
22 UIKit 0x0058fa92 -[UINavigationTransitionView _navigationTransitionDidStop] + 55
23 UIKit 0x002996dc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
24 UIKit 0x00297ec5 +[UIViewAnimationState popAnimationState] + 334
25 UIKit 0x002ad123 +[UIView(Animation) commitAnimations] + 36
26 UIKit 0x0058f551 -[UINavigationTransitionView transition:fromView:toView:] + 2795
27 UIKit 0x0058ea5e -[UINavigationTransitionView transition:toView:] + 55
28 UIKit 0x0038f577 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3186
29 UIKit 0x0038f8cc -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
30 UIKit 0x003904e9 -[UINavigationController __viewWillLayoutSubviews] + 57
31 UIKit 0x004d10d1 -[UILayoutContainerView layoutSubviews] + 213
32 UIKit 0x002b8964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
33 libobjc.A.dylib 0x0159b82b -[NSObject performSelector:withObject:] + 70
34 QuartzCore 0x03c7545a -[CALayer layoutSublayers] + 148
35 QuartzCore 0x03c69244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
36 QuartzCore 0x03c753a5 -[CALayer layoutIfNeeded] + 160
37 UIKit 0x0037aae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
38 UIKit 0x00290aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
39 UIKit 0x0028f646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
40 UIKit 0x0028f518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
41 UIKit 0x0028f5a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
42 UIKit 0x0028e63a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
43 UIKit 0x0028e59c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
44 UIKit 0x0028f2f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
45 UIKit 0x002928e6 -[UIWindow setDelegate:] + 449
46 UIKit 0x0036cb77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
47 UIKit 0x00288474 -[UIWindow addRootViewControllerViewIfPossible] + 591
48 UIKit 0x002885ef -[UIWindow _setHidden:forced:] + 312
49 UIKit 0x0028886b -[UIWindow _orderFrontWithoutMakingKey] + 49
50 UIKit 0x002933c8 -[UIWindow makeKeyAndVisible] + 65
51 UIKit 0x00243bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
52 UIKit 0x00248667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
53 UIKit 0x0025cf92 -[UIApplication handleEvent:withNewEvent:] + 3517
54 UIKit 0x0025d555 -[UIApplication sendEvent:] + 85
55 UIKit 0x0024a250 _UIApplicationHandleEvent + 683
56 GraphicsServices 0x037fff02 _PurpleEventCallback + 776
57 GraphicsServices 0x037ffa0d PurpleEventCallback + 46
58 CoreFoundation 0x01785ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
59 CoreFoundation 0x017859db __CFRunLoopDoSource1 + 523
60 CoreFoundation 0x017b068c __CFRunLoopRun + 2156
61 CoreFoundation 0x017af9d3 CFRunLoopRunSpecific + 467
62 CoreFoundation 0x017af7eb CFRunLoopRunInMode + 123
63 UIKit 0x00247d9c -[UIApplication _run] + 840
64 UIKit 0x00249f9b UIApplicationMain + 1225
65 Timesheet 0x0000b60d main + 141
66 libdyld.dylib 0x01eeb701 start + 1
67 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Have you looked into:
2014-05-29 10:34:35.723 Timesheet[14438:60b] -[UITableViewCell setAlternateRowColor:]
?
setAlternateRowColor is not a valid setter on UITableViewCell. without seeing the code it's difficult to guess what the error might be, but you are using the cell improperly.

Resources