Posts

Post not yet marked as solved
4 Replies
1.3k Views
I am trying to build a Table using SwiftUI that has 14 columns. If I enter that many TableColumns under Table, I get the "The compiler is unable to type-check..." error. In fact, I get that error until I cut it back to 10 columns. My Columns all look something like this, with different name and value paths, of course:             TableColumn("Loc", value: \.location) I have seen that the way around this error is to break up the expression into something simpler. But I can't figure out how to simplify the number of columns. Any ideas? Thanks, Don
Posted
by decarlile.
Last updated
.
Post marked as solved
1 Replies
1.4k Views
Hi, I'm working on a SwiftUI Table based app for macOS (primarily, maybe other devices if I can make it work). My data consists of 14 fields, and since the SwiftUI ViewBuilder can only deal with 10 items, I have to show a subset. But I want to make them all available to users. Likewise, it does not appear that SwiftUI tables allow live editing of the data, so I will also need a way to provide that feature. But this question deals with the display of all the data. I have tried using sheets and Navigation, but I am not happy with the results to date. I created a column which has an HStack with buttons for viewing and editing. To create a sheet, I used this code: TableColumn("View/Edit") { channel in                  HStack {                      Button {                          showingViewSheet.toggle()                     } label: {                         Label("", systemImage: "eye")                     }                 .sheet(isPresented:$showingViewSheet) {                     VStack {                         ChannelDetailView(channel: channel)                         Spacer()                         Button("Dismiss") {                             showingViewSheet.toggle()                         }                     }                     .padding()                 }                     Button {                         editChannel(channel: channel)                     } label: {                         Label("", systemImage: "pencil")                     }                 }              } The result would be acceptable: But there is a big problem. It is showing the info for the zeroth item in the array. If I click on the eye in the second row, the zeroth info still is displayed. There is also a weird artifact that on dismissal, the sheet vanishes, then reappears, then finally vanishes. So, the Navigation code looks like this: var body: some View {         NavigationView {             Table(channels, selection: $selection, sortOrder: $sortOrder) { . . .                 TableColumn("View/Edit") { channel in                      HStack {                          NavigationLink(destination: ChannelDetailView(channel: channel)) {                              Label("", systemImage: "eye")                          } . . . Initially the result of this puzzled me: But after some thought, I realized that NavigationView was stuffing my entire table into a sidebar. When I resized the sidebar, I got something like what I want: This at least displayed the detail correctly. But it is not what I want. The detail is not reflective of the document in total, so should not have the title bar over it. I' thinking overlay or ZStack, but I thought I would ask to see if I am doing something wrong with the sheet, or if there is a way to make Navigation work the way I want to, or if there is some other best practice I am missing. Many thanks! Don Carlile
Posted
by decarlile.
Last updated
.
Post not yet marked as solved
0 Replies
313 Views
The macOS app I am working on displays an image in an NSImageView subclass. I want the user to be able to drag that image to the Finder to make a file and to other applications which can accept an image drop. To that end, my subclass adopts both the NSFilePromiseProviderDelegate and the NSPasteboardItemDataProvider protocols. I create dragging items using both protocols, and begin the dragging session with an array including both items.Functionally, this works just the way I want it to. A drag to the Finder creates a file. A drag to an app that can accept an image drop places the image at the insertion point as expected.The only fly in this particular ointment is the badge on the dragging image shows 2. My concern is that the user might get confused and think that 2 images are being dragged. Other apps that do this, in particular Photos and Safari, do not show the badge.Am I doing something wrong? Is there a way to do this that does not display the 2 item badge?Thanks in advance.Don Carlile
Posted
by decarlile.
Last updated
.