Reputation: 33
I like to test if the variable is nil because it is set when a connection to the server is established. But when I do I receive an EXC_BREAKPOINT code=1. I can't figure out why. Here's the code:
struct CategoryView: View {
@ObservedObject var viewRouter: ViewRouter
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
NavigationView {
if (viewRouter.menuStructure != nil) {
CategoryPage(viewRouter: viewRouter, settingsShown: true, pageTitle: "Räume", items: viewRouter.menuStructure?.items ?? [])
}
}
.edgesIgnoringSafeArea(.top)
}
bt in debugger shows the following:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1a1d79bd4) * frame #0: 0x00000001a1d79bd4 SwiftUI`SwiftUI.ColumnNavigationView.BodyContent.body.getter : some + 944 frame #1: 0x00000001a1ba22f4 SwiftUI`generic specialization of SwiftUI.ViewBodyAccessor.updateBody(of: A, changed: Swift.Bool) -> () + 1276 frame #2: 0x00000001a1cac218 SwiftUI`generic specialization >.0, SwiftUI.StaticBody>> of implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 40 frame #3: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #4: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #5: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #6: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #7: 0x00000001a1a5923c SwiftUI`generic specialization >, SwiftUI.MulticolumnSplitView>, SwiftUI.MulticolumnSplitView, Swift.AnyHashable, SwiftUI._VariadicView_Children.Element>>>> of (extension in SwiftUI):SwiftUI._ConditionalContent.(ChildView in _1A625ACC143FD8524C590782FD8F4F8C).content.getter : SwiftUI._ConditionalContent + 48 frame #8: 0x00000001a1a59d78 SwiftUI`generic specialization >, SwiftUI.MulticolumnSplitView>, SwiftUI.MulticolumnSplitView, Swift.AnyHashable, SwiftUI._VariadicView_Children.Element>>>> of (extension in SwiftUI):SwiftUI._ConditionalContent.(ChildView in _1A625ACC143FD8524C590782FD8F4F8C).value.getter : SwiftUI.AnyView + 40 frame #9: 0x00000001a1a7c230 SwiftUI`merged generic specialization , SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>, SwiftUI._AlignmentLayout>, SwiftUI._PaddingLayout>, SwiftUI._PaddingLayout>, SwiftUI.SizeLimitLayout>, SwiftUI._BackgroundModifier, SwiftUI.ModifiedContent, SwiftUI._FrameLayout>, SwiftUI._PushPopTransactionModifier>, SwiftUI._OffsetEffect>)>>>>, SwiftUI._BackgroundModifier, SwiftUI.ModifiedContent, SwiftUI._FrameLayout>, SwiftUI._PushPopTransactionModifier>, SwiftUI._OffsetEffect>)>>>>, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI.ModifiedContent, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>, SwiftUI._AlignmentLayout>, SwiftUI._PaddingLayout>, SwiftUI._PaddingLayout>, SwiftUI.SizeLimitLayout>, SwiftUI._BackgroundModifier, SwiftUI.ModifiedContent, SwiftUI._FrameLayout>, SwiftUI._PushPopTransactionModifier>, SwiftUI._OffsetEffect>)>>>>, SwiftUI._BackgroundModifier, SwiftUI.ModifiedContent, SwiftUI._FrameLayout>, SwiftUI._PushPopTransactionModifier>, SwiftUI._OffsetEffect>)>>>>, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>>, SwiftUI._EnvironmentKeyWritingModifier>>>.(ChildView in _1A625ACC143FD8524C590782FD8F4F8C)> of implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 32 frame #10: 0x00000001a1a9fcd8 SwiftUI`partial apply forwarder for generic specialization >, SwiftUI.MulticolumnSplitView>, SwiftUI.MulticolumnSplitView, Swift.AnyHashable, SwiftUI._VariadicView_Children.Element>>>>.(ChildView in _1A625ACC143FD8524C590782FD8F4F8C)> of implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 28 frame #11: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #12: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #13: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #14: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #15: 0x00000001a2069728 SwiftUI`SwiftUI.(AnyViewList in _A96961F3546506F21D8995C6092F15B5).updateValue() -> () + 60 frame #16: 0x00000001a1cd0434 SwiftUI`partial apply forwarder for generic specialization of implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 24 frame #17: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #18: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #19: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #20: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #21: 0x00000001a1e85f74 SwiftUI`SwiftUI.(DynamicLayoutViewAdaptor in _8B9C7F39264416187A895085215951BC).updatedItems() -> Swift.Optional + 64 frame #22: 0x00000001a1bc1fe0 SwiftUI`generic specialization of SwiftUI.DynamicContainerInfo.(updateItems in _023AA827B8A8D39774F7A0C281455FEE)(disableTransitions: Swift.Bool) -> (changed: Swift.Bool, hasDepth: Swift.Bool) + 68 frame #23: 0x00000001a1bc106c SwiftUI`generic specialization of SwiftUI.DynamicContainerInfo.updateValue() -> () + 340 frame #24: 0x00000001a1cb1514 SwiftUI`partial apply forwarder for generic specialization > of implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 24 frame #25: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #26: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #27: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #28: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #29: 0x00000001a1d37768 SwiftUI`SwiftUI.(DynamicPreferenceCombiner in _023AA827B8A8D39774F7A0C281455FEE).info.getter : Swift.Optional + 96 frame #30: 0x00000001a1d37960 SwiftUI`SwiftUI.(DynamicPreferenceCombiner in _023AA827B8A8D39774F7A0C281455FEE).value.getter : A.Value + 204 frame #31: 0x00000001a1ae2f9c SwiftUI`implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 124 frame #32: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #33: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #34: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #35: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #36: 0x00000001a1d37c14 SwiftUI`SwiftUI.(DynamicPreferenceCombiner in _023AA827B8A8D39774F7A0C281455FEE).value.getter : A.Value + 896 frame #37: 0x00000001a1ae2f9c SwiftUI`implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 124 frame #38: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #39: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #40: 0x00000001c39b06f8 AttributeGraph`AG::Graph::input_value_ref_slow(AG::data::ptr, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 384 frame #41: 0x00000001c39c272c AttributeGraph`AGGraphGetValue + 232 frame #42: 0x00000001a2009d90 SwiftUI`SwiftUI.(HostPreferencesTransform in _5EC2B8E51282B711F818D51701767C64).updateValue() -> () + 88 frame #43: 0x00000001a1d3ec10 SwiftUI`partial apply forwarder for implicit closure #2 (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in implicit closure #1 (A1.Type) -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 () -> (Swift.UnsafeMutableRawPointer, __C.AGAttribute) -> () in closure #1 (Swift.UnsafePointer) -> AttributeGraph.Attribute in AttributeGraph.Attribute.init(A1) -> AttributeGraph.Attribute + 32 frame #44: 0x00000001c39aabc0 AttributeGraph`AG::Graph::UpdateStack::update() + 492 frame #45: 0x00000001c39aaff4 AttributeGraph`AG::Graph::update_attribute(AG::data::ptr, bool) + 332 frame #46: 0x00000001c39b0154 AttributeGraph`AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, bool*) + 156 frame #47: 0x00000001c39c2774 AttributeGraph`AGGraphGetValue + 304 frame #48: 0x00000001a236d5b8 SwiftUI`SwiftUI.GraphHost.updatePreferences() -> Swift.Bool + 56 frame #49: 0x00000001a1e5b9d4 SwiftUI`SwiftUI.ViewGraph.updateOutputs(at: SwiftUI.Time) -> () + 112 frame #50: 0x00000001a22c2eac SwiftUI`closure #1 () -> () in (extension in SwiftUI):SwiftUI.ViewRendererHost.render(interval: Swift.Double, updateDisplayList: Swift.Bool) -> () + 1444 frame #51: 0x00000001a22ba090 SwiftUI`(extension in SwiftUI):SwiftUI.ViewRendererHost.render(interval: Swift.Double, updateDisplayList: Swift.Bool) -> () + 340 frame #52: 0x00000001a243ee00 SwiftUI`SwiftUI._UIHostingView.layoutSubviews() -> () + 176 frame #53: 0x00000001a243ee34 SwiftUI`@objc SwiftUI._UIHostingView.layoutSubviews() -> () + 28 frame #54: 0x000000019e383d90 UIKitCore`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2504 frame #55: 0x000000019e899384 QuartzCore`-[CALayer layoutSublayers] + 308 frame #56: 0x000000019e899858 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 524 frame #57: 0x000000019e8adff8 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 frame #58: 0x000000019e7f3ee0 QuartzCore`CA::Context::commit_transaction(CA::Transaction*, double, double*) + 416 frame #59: 0x000000019e81f36c QuartzCore`CA::Transaction::commit() + 732 frame #60: 0x000000019de55240 UIKitCore`__34-[UIApplication _firstCommitBlock]_block_invoke_2 + 84 frame #61: 0x000000019b40449c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 frame #62: 0x000000019b4036e4 CoreFoundation`__CFRunLoopDoBlocks + 408 frame #63: 0x000000019b3fdaa0 CoreFoundation`__CFRunLoopRun + 844 frame #64: 0x000000019b3fd21c CoreFoundation`CFRunLoopRunSpecific + 600 frame #65: 0x00000001b247c784 GraphicsServices`GSEventRunModal + 164 frame #66: 0x000000019de36200 UIKitCore`-[UIApplication _run] + 1072 frame #67: 0x000000019de3ba74 UIKitCore`UIApplicationMain + 168 frame #68: 0x00000001a22fcb20 SwiftUI`closure #1 (Swift.UnsafeMutablePointer>>) -> Swift.Never in SwiftUI.(KitRendererCommon in _ACC2C5639A7D76F611E170E831FCA491)(Swift.AnyObject.Type) -> Swift.Never + 112 frame #69: 0x00000001a22fcaac SwiftUI`SwiftUI.runApp(A) -> Swift.Never + 220 frame #70: 0x00000001a1e54e5c SwiftUI`static (extension in SwiftUI):SwiftUI.App.main() -> () + 140 frame #71: 0x0000000102377478 JarvisHome`static JarvisHomeApp.$main(self=JarvisHome.JarvisHomeApp) at :0 frame #72: 0x0000000102379cf8 JarvisHome`main at JarvisHomeApp.swift:0 frame #73: 0x000000019b0bd6c0 libdyld.dylib`start + 4
Any suggestions why? If i comment out the if line code isn't crashing.
EDIT: ViewRouter.swift
import Foundation
import Combine
import SwiftUI
class ViewRouter: ObservableObject {
let objectWillChange = PassthroughSubject<ViewRouter, Never>()
var currentPage: String = "myhome" {
didSet {
objectWillChange.send(self)
}
}
var symcSocketStatus: String = "connecting" {
didSet {
objectWillChange.send(self)
}
}
var syncSocketStatusShown: Bool = true {
didSet {
objectWillChange.send(self)
}
}
var settingsShown: Bool = false {
didSet {
objectWillChange.send(self)
}
}
var menuStructure: MenuItem? = nil {
didSet {
objectWillChange.send(self)
}
}
}
EDIT: MenuItem.swift
import Foundation
struct MenuItem: Codable {
//var data: [String: Any]
var disabled: Bool
var hidden: Bool
var icon: String?
var id: Int
var ident: String
var info: String
var items: [MenuItem]?
var name: String
var parentId: Int?
var position: Int
var readOnly: Bool
var summary: String
var type: Int
init() {
// self.data = ["": ""]
self.disabled = true
self.hidden = false
self.icon = ""
self.id = -1
self.ident = ""
self.info = ""
self.items = []
self.name = "Unknown"
self.parentId = 0
self.position = 0
self.readOnly = true
self.summary = ""
self.type = -1
}
}
Upvotes: 1
Views: 705
Reputation: 8547
Finally could recreate that issue.. it appear to be a issue that you are not having an view inside NavigationView
in case your if returns false. Just add a else case with any view to resolve this issue
struct ContentView: View {
@ObservedObject var viewRouter: ViewRouter
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
NavigationView {
if (viewRouter.menuStructure != nil) {
CategoryPage(viewRouter: viewRouter, settingsShown: true, pageTitle: "Räume", items: viewRouter.menuStructure?.items ?? [])
}
else {
Text("Menu Structure not loaded") //<< Some View where
}
}
.edgesIgnoringSafeArea(.top)
}
}
Upvotes: 3