Post

Replies

Boosts

Views

Activity

Reply to I get this Issue : ContentView.swift:3016:25 The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions. But I don´t know what I have to do. I am a noob. Can anybody help me.
Welcome to the forum. But your post is really badly written: When you post code, use code formatter to make your code readable. avoid duplicating the post provide all structure definitions, otherwise impossible to test and investigate. make sure the code you post does compile: What are: OrderItem MenuCategory etc Your code compile with those error. What di you post ? Real code ? An edited version (bad idea): @Environment(.dismiss) private var dismiss It should be @Environment(\.dismiss) private var dismiss This as well if MenuCategory is a type definition and not a var ForEach(MenuCategory) { category in struct OrderRow: View is declared twice
Nov ’24
Reply to Limiting the Number of Bool (True) Values
If I understand well, you want to allow a max of 2 checked on. And nothing should happen if trying to check a third (except maybe an error message). Here is how I did this: struct ContentView: View { @State private var viewModel = ContentViewModel() @State var allowMoreChecks = true // <<-- ADDED var body: some View { VStack(alignment: .leading) { List { ForEach(viewModel.models, id: \.id) { model in CheckButtonView(id: model.id, text: model.name, isOn: model.isOn, moreAllowed: allowMoreChecks) { id, bool in updateDate(id: id, bool: bool) // <<-- ADDED moreAllowed } } } } } func updateDate(id: String, bool: Bool) { for i in 0..<viewModel.models.count { let oldModel = viewModel.models[i] if oldModel.id == id { let newModel = Content(id: oldModel.id, name: oldModel.name, isOn: bool) viewModel.models.remove(at: i) viewModel.models.insert(newModel, at: i) break } } var count = 0 for i in 0..<viewModel.models.count { let model = viewModel.models[i] if model.isOn { count += 1 } } allowMoreChecks = count < 2 // <<-- ADDED } } struct CheckButtonView: View { let id: String let text: String @State var isOn: Bool var moreAllowed : Bool // <<-- ADDED var callBack: (String, Bool) -> Void var body: some View { HStack { Button { if !moreAllowed && !isOn {. // <<-- ADDED print("not authorized") } else { isOn.toggle() callBack(id, isOn) } } label: { Image(systemName: isOn ? "checkmark.square.fill" : "square") .resizable() .aspectRatio(contentMode: .fit) .frame(width: 18) .tint(!isOn ? .black : .blue) } Text(text) .font(.subheadline) Spacer() } .frame(maxWidth: .infinity) } } struct Content { let id: String let name: String let isOn: Bool } class ContentViewModel: ObservableObject { @Published var models = [Content]() @Published var canChange = true init() { models = [ Content(id: UUID().uuidString, name: "Jim", isOn: false), Content(id: UUID().uuidString, name: "Jenny", isOn: false), Content(id: UUID().uuidString, name: "Nancy", isOn: false), Content(id: UUID().uuidString, name: "Natalie", isOn: false) ] } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Reply to 4.3 A Spam Design
So, the previous app is no more available on the appstore ? Did the previous company provide to the new company an official letter certifying they have transferred all the rights on the app ? That could be a first step to try to prove reviewers that it is not a spam. But not sure it would be enough. Anyway, you could try.
Nov ’24
Reply to Unable to Create Files Adjacent to User-Selected File Due to App Sandbox Permissions
If I understand your question correctly, you can grant access to a directory as well. What @DTS Engineer said, plus… The way I do this is in 2 steps: A first NSPanel asks for Directory to select Then, in the openPanel.begin() closure I ask for saving the file Now, you will be able to save in this Directory let openPanel = NSOpenPanel() // to authorize access to directory openPanel.message = NSLocalizedString("Select Directory)", comment: "") openPanel.prompt = NSLocalizedString("Select", comment: "") openPanel.canChooseFiles = false openPanel.canChooseDirectories = true // To select directrory openPanel.canCreateDirectories = true openPanel.begin() { (result2) -> Void in if result2 == NSApplication.ModalResponse.OK { // When obtaining access through NSOpenPanel, you don't need to call startAccessingSecurityScopedResource() and stopAccessingSecurityScopedResource(), because the user explicitly granted you access for this session. let folderUrl = openPanel.url! // Create file let savePanel = NSSavePanel() savePanel.title = NSLocalizedString("File", comment: "") savePanel.nameFieldStringValue = "" // nothing here, will be entered by user savePanel.prompt = NSLocalizedString("Create", comment: "") savePanel.allowedFileTypes = ["XXXX"] // your type let fileManager = FileManager.default // Define new file name savePanel.begin() { (result) -> Void in if result == NSApplication.ModalResponse.OK { // write the file // save bookmarks } } Hope that helps.
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’24
Reply to Can someone help me fix this code.
You already posted the same question a few days ago and told it was solved. What is the new issue ? For the first error, let fetchedUser = try snapshot.data(as:User.self) I searched Firestore doc https://firebase.google.com/docs/firestore/solutions/swift-codable-data-mapping They show some sample code private func fetchBook(documentId: String) { let docRef = db.collection("books").document(documentId) docRef.getDocument(as: Book.self) { result in Book is Codable struct Book: Codable { @DocumentID var id: String? var title: String var numberOfPages: Int var author: String } Have you declared User as Codable ? See also this post: https://stackoverflow.com/questions/72103380/how-do-i-read-a-users-firestore-map-to-a-swift-dictionary For the second error, I think it was answered in reply to your previous post. remove coder parameter or call User with only coder parameter
Nov ’24
Reply to Unable to change TabView's background color
Did you try one of the many solutions proposed in this old thread ? https://forums.developer.apple.com/forums/thread/121799
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to I get this Issue : ContentView.swift:3016:25 The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions. But I don´t know what I have to do. I am a noob. Can anybody help me.
Welcome to the forum. But your post is really badly written: When you post code, use code formatter to make your code readable. avoid duplicating the post provide all structure definitions, otherwise impossible to test and investigate. make sure the code you post does compile: What are: OrderItem MenuCategory etc Your code compile with those error. What di you post ? Real code ? An edited version (bad idea): @Environment(.dismiss) private var dismiss It should be @Environment(\.dismiss) private var dismiss This as well if MenuCategory is a type definition and not a var ForEach(MenuCategory) { category in struct OrderRow: View is declared twice
Replies
Boosts
Views
Activity
Nov ’24
Reply to Worst update to photos app ever
You may have read what is the general feedback on new photo app. Mixed feelings to say the least: https://www.macrumors.com/2024/11/21/apples-photos-app-overhaul-controversial/
Replies
Boosts
Views
Activity
Nov ’24
Reply to Limiting the Number of Bool (True) Values
If I understand well, you want to allow a max of 2 checked on. And nothing should happen if trying to check a third (except maybe an error message). Here is how I did this: struct ContentView: View { @State private var viewModel = ContentViewModel() @State var allowMoreChecks = true // <<-- ADDED var body: some View { VStack(alignment: .leading) { List { ForEach(viewModel.models, id: \.id) { model in CheckButtonView(id: model.id, text: model.name, isOn: model.isOn, moreAllowed: allowMoreChecks) { id, bool in updateDate(id: id, bool: bool) // <<-- ADDED moreAllowed } } } } } func updateDate(id: String, bool: Bool) { for i in 0..<viewModel.models.count { let oldModel = viewModel.models[i] if oldModel.id == id { let newModel = Content(id: oldModel.id, name: oldModel.name, isOn: bool) viewModel.models.remove(at: i) viewModel.models.insert(newModel, at: i) break } } var count = 0 for i in 0..<viewModel.models.count { let model = viewModel.models[i] if model.isOn { count += 1 } } allowMoreChecks = count < 2 // <<-- ADDED } } struct CheckButtonView: View { let id: String let text: String @State var isOn: Bool var moreAllowed : Bool // <<-- ADDED var callBack: (String, Bool) -> Void var body: some View { HStack { Button { if !moreAllowed && !isOn {. // <<-- ADDED print("not authorized") } else { isOn.toggle() callBack(id, isOn) } } label: { Image(systemName: isOn ? "checkmark.square.fill" : "square") .resizable() .aspectRatio(contentMode: .fit) .frame(width: 18) .tint(!isOn ? .black : .blue) } Text(text) .font(.subheadline) Spacer() } .frame(maxWidth: .infinity) } } struct Content { let id: String let name: String let isOn: Bool } class ContentViewModel: ObservableObject { @Published var models = [Content]() @Published var canChange = true init() { models = [ Content(id: UUID().uuidString, name: "Jim", isOn: false), Content(id: UUID().uuidString, name: "Jenny", isOn: false), Content(id: UUID().uuidString, name: "Nancy", isOn: false), Content(id: UUID().uuidString, name: "Natalie", isOn: false) ] } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to SwiftUI App crashes while switching orientation
Welcome to the forum. Could you post minimal code so that we can try to reproduce and try to understand ? Maybe that's just an error in your code…
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to Issue with Empty Window Appearing on App Launch for macOS App - Help Needed
Could you show definition of LanguageSwitchPanel so that we can test and reproduce ?
Replies
Boosts
Views
Activity
Nov ’24
Reply to How to preview an `App` class in xcode?
If I understand your question, just use simulator. It is done to allow testing app on any type of device.
Replies
Boosts
Views
Activity
Nov ’24
Reply to Yahoo email screen
Did you try a long press on a box, to see if you get a context menu with a delete option ?
Replies
Boosts
Views
Activity
Nov ’24
Reply to 4.3 A Spam Design
So, the previous app is no more available on the appstore ? Did the previous company provide to the new company an official letter certifying they have transferred all the rights on the app ? That could be a first step to try to prove reviewers that it is not a spam. But not sure it would be enough. Anyway, you could try.
Replies
Boosts
Views
Activity
Nov ’24
Reply to nomor wa bws mobile adalah 083193926887
Surprising to see those automatic answers from App Store Connect Engineer. Really out of purpose. Looks like Apple intelligence does not apply yet to the forum 😉
Replies
Boosts
Views
Activity
Nov ’24
Reply to App Icon for a pre-order page
Could you clarify your question ? What icon do you want to upload ? Specific to each pre-order ? Where are those icons defined ?
Replies
Boosts
Views
Activity
Nov ’24
Reply to Bug temps d’écran partage familial
Bienvenue sur le forum. Vous devriez plutôt poster un Bug report ou poser la question sur la Communauté de support Apple: https://discussions.apple.com/welcome Le forum est fait pour le développement d'apps, pas pour des problèmes sur des apps existantes (sauf Xcode ou les autres outils de développement bien sûr).
Replies
Boosts
Views
Activity
Nov ’24
Reply to Unable to Create Files Adjacent to User-Selected File Due to App Sandbox Permissions
If I understand your question correctly, you can grant access to a directory as well. What @DTS Engineer said, plus… The way I do this is in 2 steps: A first NSPanel asks for Directory to select Then, in the openPanel.begin() closure I ask for saving the file Now, you will be able to save in this Directory let openPanel = NSOpenPanel() // to authorize access to directory openPanel.message = NSLocalizedString("Select Directory)", comment: "") openPanel.prompt = NSLocalizedString("Select", comment: "") openPanel.canChooseFiles = false openPanel.canChooseDirectories = true // To select directrory openPanel.canCreateDirectories = true openPanel.begin() { (result2) -> Void in if result2 == NSApplication.ModalResponse.OK { // When obtaining access through NSOpenPanel, you don't need to call startAccessingSecurityScopedResource() and stopAccessingSecurityScopedResource(), because the user explicitly granted you access for this session. let folderUrl = openPanel.url! // Create file let savePanel = NSSavePanel() savePanel.title = NSLocalizedString("File", comment: "") savePanel.nameFieldStringValue = "" // nothing here, will be entered by user savePanel.prompt = NSLocalizedString("Create", comment: "") savePanel.allowedFileTypes = ["XXXX"] // your type let fileManager = FileManager.default // Define new file name savePanel.begin() { (result) -> Void in if result == NSApplication.ModalResponse.OK { // write the file // save bookmarks } } Hope that helps.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to Customizing Tables in SwiftUI
Is it for MacApp ? If so, look here: https://stackoverflow.com/questions/75444832/change-table-background-color-swiftui
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Nov ’24
Reply to Can someone help me fix this code.
You already posted the same question a few days ago and told it was solved. What is the new issue ? For the first error, let fetchedUser = try snapshot.data(as:User.self) I searched Firestore doc https://firebase.google.com/docs/firestore/solutions/swift-codable-data-mapping They show some sample code private func fetchBook(documentId: String) { let docRef = db.collection("books").document(documentId) docRef.getDocument(as: Book.self) { result in Book is Codable struct Book: Codable { @DocumentID var id: String? var title: String var numberOfPages: Int var author: String } Have you declared User as Codable ? See also this post: https://stackoverflow.com/questions/72103380/how-do-i-read-a-users-firestore-map-to-a-swift-dictionary For the second error, I think it was answered in reply to your previous post. remove coder parameter or call User with only coder parameter
Replies
Boosts
Views
Activity
Nov ’24