Posts

Post marked as solved
7 Replies
I investigated right today a similar issue happening in my code.The error Thread 1: EXC_BAD_ACCESS (code=2, address=0x101744d41) was happening at line 8 var emptyUsersListView: some View { List { EmptyView() } .navigationBarItems(trailing: Button(store.state.loginButtonText) { self.store.send(.tapOnLogin) } ) }After hours of digging, I narrowed it down to the Store class.The crashed thread stack trace gave me the hint: the top frame is about the objectWillChangePublisher of Combine ObservableObject.#0 0x0000000101744d41 in got.$s25ObjectWillChangePublisher7Combine010ObservableA0PTl () #1 0x0000000101571bcb in closure #2 in RootContainerView.emptyUsersListView.getter #2 0x00007fff2c014579 in PrimitiveButtonStyleConfiguration.trigger() () #3 0x00007fff2c12bd20 in partial apply for PrimitiveButtonStyleConfiguration.trigger() () #4 0x00007fff2c35b67a in closure #1 in PressableGestureCallbacks.dispatch(phase:state:) () #5 0x00007fff2c1b7cec in thunk for @escaping @callee_guaranteed () -> () () #6 0x00007fff2c316d21 in partial apply for thunk for @escaping @callee_guaranteed () -> () () #7 0x00007fff2c317b79 in thunk for @escaping @callee_guaranteed () -> ()partial apply ()So I had a closer look at the Store class, whose property sections look a bit like this. // MARK: - Public properties public var objectWillChange: AnyPublisher<_Reducer.State, Never> { return objectWillChangeSubject.eraseToAnyPublisher() } public private(set) var state: _Reducer.State { willSet { objectWillChangeSubject.send(newValue) } } // MARK: - Private properties private let objectWillChangeSubject = PassthroughSubject<_Reducer.State, Never>()Do you see what your code and my code have in common? The following line: public private(set) var foo: BarSo today, just without even knowing what I was doing, I changed the access modifiers of foo to public var foo: Barand that fixed the issue!!! I checked that also this version works. public internal(set) var foo: BarNow I would love to understand why this fixed the issue.As much as I would like to know if such a fix would work in your case too.Is public private(set) the real reason of the crash?My Store class would be way more robust with the private modifier, but meanwhile, I can live with the less restricted modifier.