I'm getting this crash report from Crashlytics. Does anyone know why's this happening? Please help me. Thanks.
Fatal Exception: NSInternalInconsistencyException UICollectionView
internal inconsistency: missing final attributes for cell
<Cell_NAME: 0x1193123c0; baseClass = UICollectionViewCell;
frame = (0 716; 414 68.5); layer = <CALayer: 0x283944dc0>>; initial
attributes: <UICollectionViewLayoutAttributes: 0x12640a2d0> index
path: (<NSIndexPath: 0xac46dcd1e0749431> {length = 2, path = 3 - 0});
frame = (0 716; 414 68.5); ; layout query:
<UICollectionViewLayoutAttributes: 0x107239cb0> index path:
(<NSIndexPath: 0xac46dcd1e0749431> {length = 2, path = 3 - 0}); frame
= (0 590; 414 64); ; collection view: <UICollectionView: 0x109891000; frame = (0 0; 414 896); clipsToBounds = YES; gestureRecognizers =
<NSArray: 0x28369b3c0>; layer = <CALayer: 0x2838dff60>; contentOffset:
{0, 244}; contentSize: {414, 1253}; adjustedContentInset: {48, 0, 34,
0}; layout: <UICollectionViewCompositionalLayout: 0x107398c10>;
dataSource: <VC_NAME: 0x10e018600>>
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x990fc __exceptionPreprocess
1 libobjc.A.dylib 0x15d64 objc_exception_throw
2 Foundation 0x1303ac _userInfoForFileAndLine
3 UIKitCore 0x227808 -[UICollectionView _updateVisibleCellsNow:]
4 UIKitCore 0x17ae64 -[UICollectionView layoutSubviews]
5 UIKitCore 0x18d798 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
6 QuartzCore 0x40138 CA::Layer::layout_if_needed(CA::Transaction*)
7 QuartzCore 0x32958 CA::Layer::layout_and_display_if_needed(CA::Transaction*)
8 QuartzCore 0x46f80 CA::Context::commit_transaction(CA::Transaction*, double, double*)
9 QuartzCore 0x4f874 CA::Transaction::commit()
10 QuartzCore 0x320b0 CA::Transaction::flush_as_runloop_observer(bool)
11 CoreFoundation 0x41610 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
12 CoreFoundation 0x108f4 __CFRunLoopDoObservers
13 CoreFoundation 0xb98c __CFRunLoopRun
14 CoreFoundation 0x1f468 CFRunLoopRunSpecific
15 GraphicsServices 0x138c GSEventRunModal
16 UIKitCore 0x51a088 -[UIApplication _run]
17 UIKitCore 0x298958 UIApplicationMain
18 DocTime 0x5740 main + 20 (Model.swift:20)
19 ??? 0x10602daa4 (Missing)
Related
I got the app crashed on the iOS Simulator 16.2 when layout 2 text fields horizontally.
Step by step to reproduce on iOS Simulator 16.2:
Environments:
Xcode 14.2
iOS 16.2
Simulator
Step 1: 2 text fields (UITextField) into a horizontal stackview with leading, trailing, top and bottom constraints.
Step 2: Set a long text for both of 2 text fields (appear three dots at the end of the textfield)
Step 3: click on the first text field
Step 4: click on the second text field
Result: The app is crashed at step 4
Error information:
2023-01-30 14:16:57.647873+0700 iOS16dot2TextFieldBug[18988:1850296] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff8004288ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff80004dba3 objc_exception_throw + 48
2 CoreFoundation 0x00007ff800428789 -[NSException initWithCoder:] + 0
3 QuartzCore 0x00007ff80897d05e -[CALayer setPosition:] + 388
4 UIKitCore 0x000000010a2d90f4 -[UIView setCenter:] + 253
5 UIKitCore 0x0000000109105c2a -[_UIEditMenuPresentation _displayMenu:reason:] + 1959
6 UIKitCore 0x0000000109105387 -[_UIEditMenuPresentation displayMenu:configuration:] + 81
7 UIKitCore 0x000000010a29772a __58-[UIEditMenuInteraction presentEditMenuWithConfiguration:]_block_invoke + 207
8 UIKitCore 0x000000010a299222 __80-[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:]_block_invoke + 87
9 UIKitCore 0x000000010a0085cb __133-[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:]_block_invoke + 208
10 UIKitCore 0x000000010a008732 -[_UIContextMenuInteractionBasedTextContextInteraction _querySelectionCommandsForConfiguration:suggestedActions:completionHandler:] + 325
11 UIKitCore 0x000000010a0084da -[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:] + 126
12 UIKitCore 0x000000010a29918f -[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:] + 296
13 UIKitCore 0x000000010a297485 -[UIEditMenuInteraction presentEditMenuWithConfiguration:] + 240
14 UIKitCore 0x000000010a008d6d -[_UIContextMenuInteractionBasedTextContextInteraction presentSelectionCommandsWithConfiguration:] + 94
15 UIKitCore 0x000000010a05cb6f -[UITextSelectionView _presentEditMenuWithPreferredDirection:replacements:] + 103
16 UIKitCore 0x000000010a05c792 -[UITextSelectionView _showCommandsWithReplacements:isForContextMenu:forDictation:arrowDirection:] + 1487
17 UIKitCore 0x000000010a05c157 __77-[UITextSelectionView _showCommandsWithReplacements:forDictation:afterDelay:]_block_invoke + 262
18 libdispatch.dylib 0x000000010246bf5b _dispatch_client_callout + 8
19 libdispatch.dylib 0x000000010246f164 _dispatch_continuation_pop + 836
20 libdispatch.dylib 0x0000000102486d2e _dispatch_source_invoke + 2198
21 libdispatch.dylib 0x000000010247cbc7 _dispatch_main_queue_drain + 1065
22 libdispatch.dylib 0x000000010247c790 _dispatch_main_queue_callback_4CF + 31
23 CoreFoundation 0x00007ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
24 CoreFoundation 0x00007ff800382436 __CFRunLoopRun + 2482
25 CoreFoundation 0x00007ff8003816a7 CFRunLoopRunSpecific + 560
26 GraphicsServices 0x00007ff809cb128a GSEventRunModal + 139
27 UIKitCore 0x0000000109ccbad3 -[UIApplication _run] + 994
28 UIKitCore 0x0000000109cd09ef UIApplicationMain + 123
29 libswiftUIKit.dylib 0x0000000102a18c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
30 iOS16dot2TextFieldBug 0x000000010223c908 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
31 iOS16dot2TextFieldBug 0x000000010223c897 $s21iOS16dot2TextFieldBug11AppDelegateC5$mainyyFZ + 39
32 iOS16dot2TextFieldBug 0x000000010223c988 main + 24
33 dyld 0x00000001025912bf start_sim + 10
34 ??? 0x0000000102375310 0x0 + 4332147472
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 (BA2F723B-EEE6-48D0-89DD-9DAEC9E9A11E) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14
I just got this issue on iOS Simulator 16.2. Everything is normal on the lower than iOS 16.2.
Full of code here
I don't know this is an issue from iOS 16.2 or not.
Have you seen this issue? Please help me fix it if you can.
Thank you.
It certainly appears to be a bug.
One work-around is to add this in viewDidLoad() (or set in Storyboard):
[emailTextField, websiteTextField].forEach {
if let tf = $0 {
tf.autocorrectionType = .no
tf.spellCheckingType = .no
}
}
Your example is looking for "email" and "website" entries, so you probably don't want/need those anyway.
I got the app crashed on the iOS Simulator 16.2 when layout 2 text fields horizontally.
Step by step to reproduce on iOS Simulator 16.2:
Environments:
Xcode 14.2
iOS 16.2
Simulator
Step 1: 2 text fields (UITextField) into a horizontal stackview with leading, trailing, top and bottom constraints.
Step 2: Set a long text for both of 2 text fields (appear three dots at the end of the textfield)
Step 3: click on the first text field
Step 4: click on the second text field
Result: The app is crashed at step 4
Error information:
2023-01-30 14:16:57.647873+0700 iOS16dot2TextFieldBug[18988:1850296] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff8004288ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff80004dba3 objc_exception_throw + 48
2 CoreFoundation 0x00007ff800428789 -[NSException initWithCoder:] + 0
3 QuartzCore 0x00007ff80897d05e -[CALayer setPosition:] + 388
4 UIKitCore 0x000000010a2d90f4 -[UIView setCenter:] + 253
5 UIKitCore 0x0000000109105c2a -[_UIEditMenuPresentation _displayMenu:reason:] + 1959
6 UIKitCore 0x0000000109105387 -[_UIEditMenuPresentation displayMenu:configuration:] + 81
7 UIKitCore 0x000000010a29772a __58-[UIEditMenuInteraction presentEditMenuWithConfiguration:]_block_invoke + 207
8 UIKitCore 0x000000010a299222 __80-[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:]_block_invoke + 87
9 UIKitCore 0x000000010a0085cb __133-[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:]_block_invoke + 208
10 UIKitCore 0x000000010a008732 -[_UIContextMenuInteractionBasedTextContextInteraction _querySelectionCommandsForConfiguration:suggestedActions:completionHandler:] + 325
11 UIKitCore 0x000000010a0084da -[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:] + 126
12 UIKitCore 0x000000010a29918f -[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:] + 296
13 UIKitCore 0x000000010a297485 -[UIEditMenuInteraction presentEditMenuWithConfiguration:] + 240
14 UIKitCore 0x000000010a008d6d -[_UIContextMenuInteractionBasedTextContextInteraction presentSelectionCommandsWithConfiguration:] + 94
15 UIKitCore 0x000000010a05cb6f -[UITextSelectionView _presentEditMenuWithPreferredDirection:replacements:] + 103
16 UIKitCore 0x000000010a05c792 -[UITextSelectionView _showCommandsWithReplacements:isForContextMenu:forDictation:arrowDirection:] + 1487
17 UIKitCore 0x000000010a05c157 __77-[UITextSelectionView _showCommandsWithReplacements:forDictation:afterDelay:]_block_invoke + 262
18 libdispatch.dylib 0x000000010246bf5b _dispatch_client_callout + 8
19 libdispatch.dylib 0x000000010246f164 _dispatch_continuation_pop + 836
20 libdispatch.dylib 0x0000000102486d2e _dispatch_source_invoke + 2198
21 libdispatch.dylib 0x000000010247cbc7 _dispatch_main_queue_drain + 1065
22 libdispatch.dylib 0x000000010247c790 _dispatch_main_queue_callback_4CF + 31
23 CoreFoundation 0x00007ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
24 CoreFoundation 0x00007ff800382436 __CFRunLoopRun + 2482
25 CoreFoundation 0x00007ff8003816a7 CFRunLoopRunSpecific + 560
26 GraphicsServices 0x00007ff809cb128a GSEventRunModal + 139
27 UIKitCore 0x0000000109ccbad3 -[UIApplication _run] + 994
28 UIKitCore 0x0000000109cd09ef UIApplicationMain + 123
29 libswiftUIKit.dylib 0x0000000102a18c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
30 iOS16dot2TextFieldBug 0x000000010223c908 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
31 iOS16dot2TextFieldBug 0x000000010223c897 $s21iOS16dot2TextFieldBug11AppDelegateC5$mainyyFZ + 39
32 iOS16dot2TextFieldBug 0x000000010223c988 main + 24
33 dyld 0x00000001025912bf start_sim + 10
34 ??? 0x0000000102375310 0x0 + 4332147472
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 (BA2F723B-EEE6-48D0-89DD-9DAEC9E9A11E) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14
I just got this issue on iOS Simulator 16.2. Everything is normal on the lower than iOS 16.2.
Full of code here
I don't know this is an issue from iOS 16.2 or not.
Have you seen this issue? Please help me fix it if you can.
Thank you.
It certainly appears to be a bug.
One work-around is to add this in viewDidLoad() (or set in Storyboard):
[emailTextField, websiteTextField].forEach {
if let tf = $0 {
tf.autocorrectionType = .no
tf.spellCheckingType = .no
}
}
Your example is looking for "email" and "website" entries, so you probably don't want/need those anyway.
It's fixed at iOS 16.1 Beta 4 ✅
There is a weird crash that only happens in iOS 16. When I try to create a TabView with page style, it's crashing when the array is empty. But it's working perfectly fine in iOS 15. Is this an iOS 16 bug?
Xcode version: Version 14.0 (14A309)
iOS Version: 16.0 & 16.1 Beta
struct TestView: View {
#State private var data: [Int] = []
var body: some View {
TabView {
ForEach(0..<data.count, id: \.self) { index in
RoundedRectangle(cornerRadius: 12)
}
}
.frame(height: 200)
.tabViewStyle(.page(indexDisplayMode: .never))
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.data = [1,2,3,4]
}
}
}
}
Crash Log
2022-10-04 18:01:56.275879+0300 TestFirebaseCrash[24331:486169] *** Assertion failure in -[_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView _validateScrollingTargetIndexPath:], UICollectionView.m:7339
2022-10-04 18:01:56.278900+0300 TestFirebaseCrash[24331:486169] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to scroll the collection view to an out-of-bounds item (0) when there are only 0 items in section 0. Collection view: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView: 0x140841e00; baseClass = UICollectionView; frame = (0 0; 428 200); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600001d8d260>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x600001386d20>; contentOffset: {0, 0}; contentSize: {0, 200}; adjustedContentInset: {0, 0, 0, 0}; layout: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF012PagingLayout: 0x140514090>; dataSource: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF011Coordinator: 0x6000021f46c0>>.'
*** First throw call stack:
(
0 CoreFoundation 0x000000018040c304 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018005131c objc_exception_throw + 56
2 Foundation 0x0000000180b11f88 _userInfoForFileAndLine + 0
3 UIKitCore 0x00000001032279a8 -[UICollectionView _validateScrollingTargetIndexPath:] + 408
4 UIKitCore 0x0000000103227cc0 -[UICollectionView _contentOffsetForScrollingToItemAtIndexPath:atScrollPosition:] + 48
5 UIKitCore 0x0000000103228838 -[UICollectionView _scrollToItemAtIndexPath:atScrollPosition:animated:] + 220
6 SwiftUI 0x0000000106f5de08 OUTLINED_FUNCTION_15 + 18076
7 SwiftUI 0x0000000106f5dea8 OUTLINED_FUNCTION_15 + 18236
8 SwiftUI 0x0000000106f5dc88 OUTLINED_FUNCTION_15 + 17692
9 SwiftUI 0x0000000106f5dcf4 OUTLINED_FUNCTION_15 + 17800
10 UIKitCore 0x0000000103ea214c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1920
11 QuartzCore 0x0000000187ed749c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 440
12 QuartzCore 0x0000000187ee1f54 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 128
13 QuartzCore 0x0000000187e117d0 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 452
14 QuartzCore 0x0000000187e3d47c _ZN2CA11Transaction6commitEv + 652
15 UIKitCore 0x0000000103a257f0 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
16 CoreFoundation 0x0000000180370e38 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
17 CoreFoundation 0x0000000180370580 __CFRunLoopDoBlocks + 364
18 CoreFoundation 0x000000018036ae7c __CFRunLoopRun + 776
19 CoreFoundation 0x000000018036a75c CFRunLoopRunSpecific + 584
20 GraphicsServices 0x0000000188f60c98 GSEventRunModal + 160
21 UIKitCore 0x0000000103a0cb74 -[UIApplication _run] + 868
22 UIKitCore 0x0000000103a10b1c UIApplicationMain + 124
23 SwiftUI 0x0000000107702130 OUTLINED_FUNCTION_51 + 496
24 SwiftUI 0x0000000107701fd8 OUTLINED_FUNCTION_51 + 152
25 SwiftUI 0x0000000106ee5894 OUTLINED_FUNCTION_10 + 88
26 TestFirebaseCrash 0x000000010269ec6c $s17TestFirebaseCrash0abC3AppV5$mainyyFZ + 40
27 TestFirebaseCrash 0x000000010269ed14 main + 12
28 dyld 0x00000001028e9fa0 start_sim + 20
29 ??? 0x00000001029bd08c 0x0 + 4338733196
30 ??? 0x1a00000000000000 0x0 + 1873497444986126336
)
libc++abi: terminating with uncaught exception of type NSException
terminating with uncaught exception of type NSException
CoreSimulator 857.10 - Device: iPhone 13 Pro Max (29ECC9E3-B223-4591-A18A-1C858F528C45) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 13 Pro Max
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to scroll the collection view to an out-of-bounds item (0) when there are only 0 items in section 0. Collection view: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView: 0x140841e00; baseClass = UICollectionView; frame = (0 0; 428 200); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600001d8d260>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x600001386d20>; contentOffset: {0, 0}; contentSize: {0, 200}; adjustedContentInset: {0, 0, 0, 0}; layout: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF012PagingLayout: 0x140514090>; dataSource: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF011Coordinator: 0x6000021f46c0>>.'
(lldb)
Try returning Text("") (basically an empty view) if data is empty.
TabView {
if data.isEmpty {
Text("")
} else {
ForEach(data, id: \.self) { _ in
RoundedRectangle(cornerRadius: 12)
}
}
}
It looks like it's fixed at iOS 16.1 Beta 4 ✅
[__NSDictionaryM safeObjectAtIndex:]: unrecognized selector sent to instance 0x60800005e060
[__NSDictionaryM safeObjectAtIndex:]: unrecognized selector sent to instance 0x60800005e060 [IssuesViewController-tableView:cellForRowAtIndexPath:]
Assertion failure in -[STCollapseTableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UITableView.m:8174
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView (; layer = ; contentOffset: {0, 0}; contentSize: {414, 115}>) failed to obtain a cell from its dataSource (; layer = ; contentOffset: {0, 0}; contentSize: {414, 115}>)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000108d8bb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001087c3141 objc_exception_throw + 48
2 CoreFoundation 0x0000000108d8fcf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010835d3b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000109aeefcf -[UITableView _configureCellForDisplay:forIndexPath:] + 230
5 UIKit 0x0000000109afa7b8 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 836
6 UIKit 0x0000000109afa9a8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
7 UIKit 0x0000000109acf2e9 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2845
8 UIKit 0x0000000109b0397c -[UITableView _performWithCachedTraitCollection:] + 111
9 UIKit 0x0000000109aeab2a -[UITableView layoutSubviews] + 233
10 UIKit 0x0000000109a5120b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
11 QuartzCore 0x0000000107905904 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x00000001078f9526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
13 QuartzCore 0x00000001078f93a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000107888e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
15 QuartzCore 0x00000001078b5130 _ZN2CA11Transaction6commitEv + 468
16 UIKit 0x0000000109987307 _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
17 UIKit 0x000000010a187cab __handleEventQueue + 5843
18 CoreFoundation 0x0000000108d31c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
19 CoreFoundation 0x0000000108d170cf __CFRunLoopDoSources0 + 527
20 CoreFoundation 0x0000000108d165ff __CFRunLoopRun + 911
21 CoreFoundation 0x0000000108d16016 CFRunLoopRunSpecific + 406
22 GraphicsServices 0x000000010b8eaa24 GSEventRunModal + 62
23 UIKit 0x000000010998e0d4 UIApplicationMain + 159
24 comress 0x000000010626910f main + 111
25 libdyld.dylib 0x000000010b4d765d start + 1)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
This is sample code:
NSArray *postDupe = [[_postsArray valueForKeyPath:#"#unionOfArrays.#allValues"] valueForKeyPath:#"post"];
NSArray *foundArray = nil;
predicate = [NSPredicate predicateWithFormat:#"post_id.stringValue contains [c] %#",#"18586"];
foundArray = [postDupe filteredArrayUsingPredicate:predicate];
long foundIndex = 0;
long count = 0;
for (int i=0; i<foundArray.count; i++)
{
foundIndex = [postDupe indexOfObject: [foundArray objectAtIndex: i]];
//NSLog(#"%# is at index %d", string, index);
}
_filterPostsArray = [_postsArray objectAtIndex:foundIndex];
}
searchActive = YES;
dispatch_async(dispatch_get_main_queue(),^{
[_issuesTable reloadData];
});
Sample Json Data:
<__NSArrayM 0x608000449a80>(
{
14556 = {
newCommentsCount = 0;
post = {
"post_id" = 18609;
seen = 1;
status = 0;
statusWasUpdated = 0;
"updated_on" = "1506061049.023";
};
};
},
)
[__NSDictionaryM safeObjectAtIndex:]: unrecognized selector sent to instance
Looks like you have a dictionary and are treating it like an array.
Run your code in the debugger and examine the values of the variables as you move through your algorithm, this should show you where you go wrong.
Guessing:
The key path in your predicate post_id.stringValue should be post.post_id.stringValue - your dictionary contains a key post whose value is itself a dictionary which has a key post_id.
_filterPostsArray = [_postsArray objectAtIndex:foundIndex] sounds like it is assigning a dictionary to an array. You probably wanted this statement to be in the loop and adding the dictionary as a new element to the array?
HTH
I'm trying to add a subview and some constraints to a scene, which is build using the interface builder.
The subview gets added correctly, but when I try to add the constraints the app crashes with the following error, which implies that I've got the view hierarchy mixed up. However I'm can't find my error.
Shopigator[14377:635114] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7fafab4bb660 THSegmentedControl:0x7fafaf03a6e0.centerX == UISearchBar:0x7fafaf0334b0.centerX>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2015-03-13 11:51:12.004 Shopigator[14377:635114] View hierarchy unprepared for constraint.
Constraint: <NSLayoutConstraint:0x7fafab4bb660 THSegmentedControl:0x7fafaf03a6e0.centerX == UISearchBar:0x7fafaf0334b0.centerX>
Container hierarchy:
<UIView: 0x7fafaf037d70; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7fafab424a00>>
| <_UILayoutGuide: 0x7fafaf037e40; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x7fafa97e4710>>
| <_UILayoutGuide: 0x7fafaf037540; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x7fafaf0ed980>>
| <UIView: 0x7fafaf035e40; frame = (0 0; 500 50); layer = <CALayer: 0x7fafaf0a9be0>>
| <THSegmentedControl: 0x7fafaf03a6e0; baseClass = UIControl; frame = (34 297; 332 29); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7fafaf0398d0>>
View not found in container hierarchy: <UISearchBar: 0x7fafaf0334b0; frame = (0 0; 320 44); text = ''; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fafb10ad1f0>; layer = <CALayer: 0x7fafab44ed10>>
That view's superview: NO SUPERVIEW
2015-03-13 11:51:12.060 Shopigator[14377:635114] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x7fafab4bb660 THSegmentedControl:0x7fafaf03a6e0.centerX == UISearchBar:0x7fafaf0334b0.centerX> view:<UIView: 0x7fafaf037d70; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7fafab424a00>>'
*** First throw call stack:
(
0 CoreFoundation 0x0000000108a2df35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001086c6bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000108a2de6d +[NSException raise:format:] + 205
3 Foundation 0x0000000107f6e0f9 -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 187
4 UIKit 0x0000000109b77de5 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
5 Foundation 0x0000000107f7bd6e -[NSISEngine withBehaviors:performModifications:] + 155
6 UIKit 0x0000000109b77beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
7 UIKit 0x0000000109b779fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
8 UIKit 0x0000000109b77671 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 404
9 UIKit 0x0000000109b78191 -[UIView(AdditionalLayoutSupport) _layoutEngineCreateIfNecessary] + 53
10 UIKit 0x0000000109b6cb0a -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 156
11 UIKit 0x0000000109b6cea4 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 30
12 UIKit 0x0000000109b6cfcc -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 243
13 Shopigator 0x0000000107507617 _TFC10Shopigator20FilterViewController11viewDidLoadfS0_FT_T_ + 9623
14 Shopigator 0x0000000107508d92 _TToFC10Shopigator20FilterViewController11viewDidLoadfS0_FT_T_ + 34
15 UIKit 0x0000000109617a90 -[UIViewController loadViewIfRequired] + 738
16 UIKit 0x0000000109617c8e -[UIViewController view] + 27
17 UIKit 0x0000000109bb941e -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
18 UIKit 0x00000001095f3429 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
19 UIKit 0x0000000109623a41 -[UIViewController _presentViewController:withAnimationController:completion:] + 1746
20 UIKit 0x0000000109625d81 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
21 UIKit 0x0000000109625ca5 -[UIViewController presentViewController:animated:completion:] + 229
22 UIKit 0x00000001094f38be -[UIApplication sendAction:to:from:forEvent:] + 75
23 UIKit 0x00000001095fa410 -[UIControl _sendActionsForEvents:withEvent:] + 467
24 UIKit 0x00000001095f97df -[UIControl touchesEnded:withEvent:] + 522
25 UIKit 0x0000000109539308 -[UIWindow _sendTouchesForEvent:] + 735
26 UIKit 0x0000000109539c33 -[UIWindow sendEvent:] + 683
27 UIKit 0x00000001095069b1 -[UIApplication sendEvent:] + 246
28 UIKit 0x0000000109513a7d _UIApplicationHandleEventFromQueueEvent + 17370
29 UIKit 0x00000001094ef103 _UIApplicationHandleEventQueue + 1961
30 CoreFoundation 0x0000000108963551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
31 CoreFoundation 0x000000010895941d __CFRunLoopDoSources0 + 269
32 CoreFoundation 0x0000000108958a54 __CFRunLoopRun + 868
33 CoreFoundation 0x0000000108958486 CFRunLoopRunSpecific + 470
34 GraphicsServices 0x000000010b2849f0 GSEventRunModal + 161
35 UIKit 0x00000001094f2420 UIApplicationMain + 1282
36 Shopigator 0x000000010748081e top_level_code + 78
37 Shopigator 0x000000010748085a main + 42
38 libdyld.dylib 0x000000010b7a8145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Relevant parts of my ViewController
#IBOutlet weak var searchBar: UISearchBar!
#IBOutlet weak var radiusSlider: LoagarithmicSlider!
var priceClassSelector: THSegmentedControl?
override func viewDidLoad() {
super.viewDidLoad()
var pCFrame = CGRectMake(34, 297, 332, 29)
self.priceClassSelector = THSegmentedControl(segments: SearchFilter.PRICE_CLASS_LABELS)
self.priceClassSelector!.frame = pCFrame
self.priceClassSelector?.setTranslatesAutoresizingMaskIntoConstraints(false)
self.view.addSubview(self.priceClassSelector!)
self.view.addConstraint(NSLayoutConstraint(
item: self.priceClassSelector!,
attribute: NSLayoutAttribute.CenterX,
relatedBy: NSLayoutRelation.Equal,
toItem: self.searchBar,
attribute: NSLayoutAttribute.CenterX,
multiplier: 1.0,
constant: 0))
}
And the view hierarchy in IB