Posts

Post not yet marked as solved
9 Replies
5.9k Views
Hey, I was testing my application and it was crashing while populating the table view. The error code is given below.2020-03-06 11:57:04.717485-0500 SkiinHeat[945:626193] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_TtC7SwiftUIP33_BFB370BA5F1BADDC9D83021565761A4925UpdateCoalescingTableView: 0x105968000; baseClass = UITableView; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x282a86f70>; layer = <CALayer: 0x28247cda0>; contentOffset: {0, 0}; contentSize: {0, 88}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <_TtGC7SwiftUIP10$1d350e2b419ListCoreCoordinatorGVS_20SystemListDataSourceOs5Never_GOS_19SelectionManagerBoxS2___: 0x104abb640>>2020-03-06 11:57:04.718056-0500 SkiinHeat[945:626193] *** Assertion failure in -[_TtC7SwiftUIP33_BFB370BA5F1BADDC9D83021565761A4925UpdateCoalescingTableView _Bug_Detected_In_Client_Of_UITableView_Invalid_Number_Of_Rows_In_Section:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.2/UITableView.m:24072020-03-06 11:57:04.718307-0500 SkiinHeat[945:626193] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'*** First throw call stack:(0x19d132a48 0x19ce59fa4 0x19d034e88 0x19d46a6c4 0x1a1355bc4 0x1a1355680 0x1a136c5cc 0x1a136c78c 0x1a136c8ec 0x1d3116020 0x1d31161bc 0x1d31187c8 0x1d3116f38 0x1d3487d90 0x1d3183d44 0x1d317e4f8 0x1d3184ff8 0x1c7c2272c 0x1c7c0b044 0x1c7c0b308 0x1c7c0fff0 0x1d3053d70 0x1d3053b28 0x1d30537c8 0x1d3053920 0x1d336942c 0x1d30538ec 0x1d30710e8 0x1d2edde9c 0x1d2edde04 0x1d2eddf14 0x19d0afe68 0x19d0aad54 0x19d0ab320 0x19d0aaadc 0x1a7030328 0x1a11a5ae0 0x1040d28c0 0x19cf34360)libc++abi.dylib: terminating with uncaught exception of type NSException.Can you please guide me on how to handle this exception.Thanks in Advance
Posted
by kdenzil.
Last updated
.
Post marked as solved
2 Replies
3.2k Views
I have 2 functions where one basically retrieves string in User Defaults and another writes the string in User Defaults. I'm not able to understand that should I do the unit test or no? and I'm pretty new to the concept for Unit testing.I scoured the internet for testing user defaults but I was advised to mock the test in the end.My question is If there is a way to test User Defaults what is the best way to do it?Constants and Structslet defaults = UserDefaults.standard let defaultinformation = "ABCDEFG" struct Keys { static let Information = "Information" }Function where saves Informationfunc SetDefaultInformation() { defaults.set(defaultinformation, forKey: Keys.Information) }Function where retrieves Informationfunc checkForInformation() -> String { let Information = defaults.value(forKey: Keys.Information) as? String ?? "" return Information }Thanks in Advance
Posted
by kdenzil.
Last updated
.