Post

Replies

Boosts

Views

Activity

Why the app is crashing when tab change (EXC_BAD_ACCESS)?
I have a custom tabbiew in my app. It works fine until I go to a subview of a tab. For example; from the Feed tab I click to Messages tab, then click to see the contents of a chat, then I click Feed tab again and crashes immediately. struct ContentView: View { //..... @StateObject var viewRouter = ViewRouter() var body: some View { GeometryReader { geometry in VStack { Spacer() switch viewRouter.currentPage { case .feed: NavigationView { FeedView(posts: feedPosts, title: "Feed") }.navigationViewStyle(.stack) case .browse: NavigationView { BrowseView(posts: browsePosts) } .navigationViewStyle(.stack) case .messages: NavigationView { ChatListView(newMessage: $newMessageAvailable) } .navigationViewStyle(.stack) //...... struct ChatListView: View { //.... var body: some View { ScrollViewReader { proxy in ScrollView { if (!gettingMessages) { if (commentArray.count > 0) { VStack{ ForEach(commentArray, id: \.chatID) { comment in NavigationLink(destination: ChatDetailView(keepViewOpen: self.$keepChatViewOpen, recipientID: getRecipientID(comment: comment), recipientName: getRecipientName(comment: comment)), isActive: self.$keepChatViewOpen , label: { ChatListItem(comment: comment, recipientName: getRecipientName(comment: comment), userID: getRecipientID(comment: comment), read: comment.read) }) } } There is nothing fancy in ChatDetailView and the crash happens for every kind of view provided that it is a view navigated from any other view with navigation link. The error is as follows: Thread 1: EXC_BAD_ACCESS (code=1, address=0xf2010803e530)
0
0
364
Apr ’22