Post

Replies

Boosts

Views

Activity

Cannot use TextEditor in .plain Window
When creating a plain window in SwiftUI on macOS 15.0 beta, the TextEditor within the window does not accept keyboard input. I suspect it's because plain windows cannot become key windows. Here is a minimal example: import SwiftUI struct ContentView: View { @State var text: String = "Hello World" var body: some View { VStack { TextEditor(text: $text) } } } @main struct BigTextApp: App { var body: some Scene { Window("Text Window", id: "TextWindow") { ContentView() } .windowStyle(.plain) } } Attempting to type gives the following warning in Xcode: Warning: -[NSWindow makeKeyWindow] called on SwiftUI.AppKitWindow which returned NO from -[NSWindow canBecomeKeyWindow]. Is there a way to make the window capable of becoming a key window without dropping down to UIKit? Or is there another way to allow the TextEditor to accept keyboard input? I have tried focusing the TextEditor, but that didn't work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2
0
560
Jun ’24
TabluarData DataFrame removing row results in EXC_BAD_ACCESS
I am working with data in Swift using the TabularData framework. I load data from a CSV file into a DataFrame, then copy the data into a second DataFrame, and finally remove a row from the second DataFrame. The problem arises when I try to remove a row from the second DataFrame, at which point I receive an EXC_BAD_ACCESS error. However, if I modify the "timings" column (the final column) before removing the row (even to an identical value), the code runs without errors. Interestingly, this issue only occurs when a row in the column of the CSV file contains more than 15 characters. This is the code I'm using: func loadCSV() { let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let url = documentsDirectory.appendingPathComponent("example.csv") var dataframe: DataFrame do { dataframe = try .init( contentsOfCSVFile: url, columns: ["user", "filename", "syllable count", "timings"], types: ["user": .string, "filename": .string, "syllable count": .integer, "timings": .string] ) } catch { fatalError("Failed to load csv data") } print("First data frame",dataframe, separator: "\n") /// This works var secondFrame = DataFrame() secondFrame.append(column: Column<String>(name: "user", capacity: 1000)) secondFrame.append(column: Column<String>(name: "filename", capacity: 1000)) secondFrame.append(column: Column<Int>(name: "syllable count", capacity: 1000)) secondFrame.append(column: Column<String>(name: "timings", capacity: 1000)) for row in 0..<dataframe.rows.count { secondFrame.appendEmptyRow() for col in 0..<4 { secondFrame.rows[row][col] = dataframe.rows[row][col] } } // secondFrame.rows[row][3, String.self] = String("0123456789ABCDEF") /* If we include this line, it will not crash, even though the content is the same */ print("Second data frame before removing row",dataframe, separator: "\n") // Before removal secondFrame.removeRow(at: 0) print("Second data frame after removing row",dataframe, separator: "\n") // After removal—we will get Thread 1: EXC_BAD_ACCESS here. The line will still print, however } and the csv (minimal example): user,filename,syllable count,timings john,john-001,12,0123456789ABCDEF jane,jane-001,10,0123456789ABCDE I've been able to replicate this bug on macOS and iOS using minimal projects. I'm unsure why this error is occurring and why modifying the "timings" column prevents it. It should be noted that this same error occurs with a single data frame loaded from a CSV file, which means that I basically cannot load from CSV if I want to modify the DataFrame afterwards.
2
1
1.1k
Aug ’23
Cannot use TextEditor in .plain Window
When creating a plain window in SwiftUI on macOS 15.0 beta, the TextEditor within the window does not accept keyboard input. I suspect it's because plain windows cannot become key windows. Here is a minimal example: import SwiftUI struct ContentView: View { @State var text: String = "Hello World" var body: some View { VStack { TextEditor(text: $text) } } } @main struct BigTextApp: App { var body: some Scene { Window("Text Window", id: "TextWindow") { ContentView() } .windowStyle(.plain) } } Attempting to type gives the following warning in Xcode: Warning: -[NSWindow makeKeyWindow] called on SwiftUI.AppKitWindow which returned NO from -[NSWindow canBecomeKeyWindow]. Is there a way to make the window capable of becoming a key window without dropping down to UIKit? Or is there another way to allow the TextEditor to accept keyboard input? I have tried focusing the TextEditor, but that didn't work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
2
Boosts
0
Views
560
Activity
Jun ’24
TabluarData DataFrame removing row results in EXC_BAD_ACCESS
I am working with data in Swift using the TabularData framework. I load data from a CSV file into a DataFrame, then copy the data into a second DataFrame, and finally remove a row from the second DataFrame. The problem arises when I try to remove a row from the second DataFrame, at which point I receive an EXC_BAD_ACCESS error. However, if I modify the "timings" column (the final column) before removing the row (even to an identical value), the code runs without errors. Interestingly, this issue only occurs when a row in the column of the CSV file contains more than 15 characters. This is the code I'm using: func loadCSV() { let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let url = documentsDirectory.appendingPathComponent("example.csv") var dataframe: DataFrame do { dataframe = try .init( contentsOfCSVFile: url, columns: ["user", "filename", "syllable count", "timings"], types: ["user": .string, "filename": .string, "syllable count": .integer, "timings": .string] ) } catch { fatalError("Failed to load csv data") } print("First data frame",dataframe, separator: "\n") /// This works var secondFrame = DataFrame() secondFrame.append(column: Column<String>(name: "user", capacity: 1000)) secondFrame.append(column: Column<String>(name: "filename", capacity: 1000)) secondFrame.append(column: Column<Int>(name: "syllable count", capacity: 1000)) secondFrame.append(column: Column<String>(name: "timings", capacity: 1000)) for row in 0..<dataframe.rows.count { secondFrame.appendEmptyRow() for col in 0..<4 { secondFrame.rows[row][col] = dataframe.rows[row][col] } } // secondFrame.rows[row][3, String.self] = String("0123456789ABCDEF") /* If we include this line, it will not crash, even though the content is the same */ print("Second data frame before removing row",dataframe, separator: "\n") // Before removal secondFrame.removeRow(at: 0) print("Second data frame after removing row",dataframe, separator: "\n") // After removal—we will get Thread 1: EXC_BAD_ACCESS here. The line will still print, however } and the csv (minimal example): user,filename,syllable count,timings john,john-001,12,0123456789ABCDEF jane,jane-001,10,0123456789ABCDE I've been able to replicate this bug on macOS and iOS using minimal projects. I'm unsure why this error is occurring and why modifying the "timings" column prevents it. It should be noted that this same error occurs with a single data frame loaded from a CSV file, which means that I basically cannot load from CSV if I want to modify the DataFrame afterwards.
Replies
2
Boosts
1
Views
1.1k
Activity
Aug ’23