Post

Replies

Boosts

Views

Activity

WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
Can anyone help to understand what is causing this warning message on this SampleCode. it happens when data in table gets updated it happens when I have lot of items in table and search for lets say # 6543 and then clear the search. "WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future." If there are just few items in table, the warning is not there. And it started when updated to Xcode Version 14 and upward import SwiftUI import Foundation @main struct TestProjectSWIFTApp: App {     @StateObject var mydata: MyData = MyData()     var body: some Scene {         WindowGroup {             ContentView()                 .environmentObject(mydata)         }              } } struct ContentView: View {     @EnvironmentObject var mydata: MyData     var body: some View {         NavigationView{             NavigationLink("TABLE",  destination: MyTable())                      }     } } struct User: Identifiable {     let id: UUID = UUID()     var name: String     var score: Int } struct MyTable: View {     @EnvironmentObject var mydata: MyData     @State private var sortOrder = [KeyPathComparator(\User.name)]     @State var searchText: String = ""     var searchResults : [User] {         if searchText.isEmpty {             return mydata.alldata         } else {             return mydata.alldata.filter{$0.name.localizedCaseInsensitiveContains(searchText)}         }     }          var body: some View {                  Button("Generate new data", action: {             mydata.updateTable()         })                  Table(searchResults, sortOrder: $sortOrder) {             TableColumn("Score"){                 Text("\(Double($0.score))")             }             TableColumn("user", value: \.name)         }         .onChange(of: sortOrder) {             mydata.alldata.sort(using: $0)         }         .searchable(text: $searchText)     } } @MainActor class MyData : ObservableObject{     @Published var alldata: [User] = []               init(){         self.setData()     }          func setData(){         alldata = [             User(name: "User 1", score: 95),             User(name: "User 2", score: 80),             User(name: "User 3", score: 85)         ]     }          func updateTable(){         var newallData: [User] = []         var x = 0         while x < 10000{             newallData.append(User(name: "User #\(x)", score:  Int.random(in: 10..<999999)))                          x = x + 1         }         alldata = newallData     }      }
17
5
3.3k
Nov ’22
Picker the selection "" is invalid and does not have an associated tag, this will give undefined results
After upgrading to macOS 13, Xcode started to print to console Picker: the selection "" is invalid and does not have an associated tag, this will give undefined results. what is wrong here? struct Piiker: View {     @State var selectOption: [String] = ["1","2","3"]     @State var fieldValue: String = ""     var body: some View {         Picker("Select number", selection: $fieldValue){             ForEach(selectOption, id: \.self){                 Text($0)             }         }     } }
4
1
6.5k
Oct ’22
How to get thumbnail as base64 string (macOS)
I don't know how to make this function to return base64encoded string of thumbnail in jpeg format.     let request = QLThumbnailGenerator         .Request(fileAt: fileURL, size: size, scale: scale,                  representationTypes: .lowQualityThumbnail)     QLThumbnailGenerator.shared.generateRepresentations(for: request)     { (thumbnail, type, error) in         DispatchQueue.main.async {             if thumbnail == nil || error != nil {                 // Handle the error case gracefully.             } else {                 // return the thumbnail as bas64 string. return ...             }         }     } }
1
0
1.1k
Jul ’22
How to test App Tracking Transparency popup message
I implemented ATT with google API. And issue is that I never see the popup message itself. I have on my test device, the Personalised Ads greyed out - (with message ..your Apple ID is associated with region where Apple-delivered ads are not available ...) So when ever I run application I get immediately response for requestTrackingAuthorization reguest - "Denied" even when I put to debug parameters notEEA and my device as testDeviceIdentifiers ... still no changes. Any clue how to get this tracking message popup appearing during testing?
1
0
1.5k
Jul ’22
How to implement Search for Table
How to filter table content based on search text, sample code: struct Person: Identifiable {     let givenName: String     let familyName: String     let index: String     let id = UUID() }     @State private var searchText: String = "" @State private var people = [     Person(givenName: "Juan", familyName: "Chavez", index: "0"),     Person(givenName: "Mei", familyName: "Chen", index: "1"),     Person(givenName: "Tom", familyName: "Clark", index: "2, id: 2"),     Person(givenName: "Gita", familyName: "Kumar", index: "3, id: 3"), ] @State private var sortOrder = [KeyPathComparator(\Person.givenName)]     @State private var selection : Person.ID?     var body: some View {     Table(people, selection: $selection, sortOrder: $sortOrder) {         TableColumn("Given Name", value: \.givenName)                  TableColumn("Family Name", value: \.familyName)     }     .onChange(of: sortOrder) {         people.sort(using: $0)     }     .searchable(text: $searchText) } }
1
0
453
Apr ’22
how to find selected row array index in Table
I have Array of 4 items, and I show 2 of them in table. And selecting the item in table, I want to print out selected row all items from array. It works only if I have not sorted the table first. As soon I sort the table I can't find reference to the array index. Is there any way to find array index? sample: struct testtable: View { struct Person: Identifiable {     let givenName: String     let familyName: String     let index: String     let id: Int } @State private var people = [     Person(givenName: "Juan", familyName: "Chavez", index: "0", id: 0),     Person(givenName: "Mei", familyName: "Chen", index: "1", id: 1),     Person(givenName: "Tom", familyName: "Clark", index: "2", id: 2),     Person(givenName: "Gita", familyName: "Kumar", index: "3", id: 3), ] @State private var sortOrder = [KeyPathComparator(\Person.givenName)] @State private var selection : Person.ID?     var body: some View {     Button(action: {         print("array[\(self.selection)]")         let arrayindex: Int = self.selection!         print(people[arrayindex])     }){         Label("Print Array Items", systemImage: "doc.text.magnifyingglass")}               Table(people, selection: $selection, sortOrder: $sortOrder) {         TableColumn("Given Name", value: \.givenName)         TableColumn("Family Name", value: \.familyName)     }     .onChange(of: sortOrder) {         people.sort(using: $0)     } } }
2
0
1.5k
Apr ’22