Post

Replies

Boosts

Views

Activity

NSSavePanel
I want to include a button that could export some data but I'm stuck: I want a NSSavePanel open up and when I choose the pass and click save the JSON file will appear but it didn't. code: Button {     let export = exportToJSON(toExported(data.data))     let openPanel = NSSavePanel()     openPanel.message = "Choose the exported path:"     openPanel.begin { response in         if response == .OK {             print("\(openPanel.url!)")             url = openPanel.url!             let fileManager = FileManager()             let success = fileManager.createFile(atPath: "\(url)", contents: export)             debugPrint(success)         }     } } label: {     Image(systemName: "square.and.arrow.down") }.padding().buttonStyle(.plain) console: file:///Users/***/Documents/Untitled false
1
0
327
May ’22
@AppStorage
Still about appstorage Can a store a @StateObject in @AppStorage? I can't do this: @AppStorage("Data") // No exact matches in call to initializer  @StateObject private var Data = TodoData()
0
0
513
May ’22
Problem
I'm trying to follow the Date Planner tutorial and the symbol picker went really weird. I changed sth, and the whole app stoped working I changed it back, it still wont work. SymbolPicker code: struct PickerView: View {     @State var item: TodoItem     @State private var showingPopover: Bool = false     var columns = Array(repeating: GridItem(.flexible()), count: 6)     var body: some View {         LazyVGrid(columns: columns){             ForEach(SymbolOptions.symbolNames, id: \.self){ symbol in                 Button {                     item.symbol = symbol                 } label: {                     Image(systemName: symbol).foregroundColor(item.color)                 }             }         }     } }
1
0
293
May ’22
Settings not showing
I'm using SwiftUI on Mac Catalyst: @main struct TodoApp: App {     @StateObject private var eventData = TodoData()     var body: some Scene {         WindowGroup {             ContentView().environmentObject(eventData)         }         #if os(macOS)         Settings{             TodoSettings()         }         #endif     } }
3
0
342
May ’22
ToolBar
I'm doing a app that needs a toolbar but it wont come out: ContentView() .toolbar {             ToolbarItem {                 Button {                     data.data.append(TodoItem())                 } label: {                     Image(systemName: "plus")                 }             }         }
1
0
539
May ’22
@AppStorage storing a self defined structure
How can I store a struct in @AppStorage? I've been trying struct TodoItem: Codable, Hashable, Identifiable {     var id: UUID = UUID()     var name: String = "New Todo"     var description: String = "Description here..."     var done: Bool } @AppStorage("todo") var todo: [TodoItem] = [] // No exact matches in call to initializer  Any help is appreciated🙏🙏
0
0
353
May ’22
NSOpenPanel malfunctioning
I have a app that needs to have a "choose file" function and I used a button hooked up to a function using NSOpenPanel to do that. But after I tried to add a drag&drop action, it wont work anymore. I revert all my files to the version when the NSOpenPanel work, but it's still the same. I also tried to restart my computer, all the same. Here's my function: private func selectFile() {         let openPanel = NSOpenPanel()         openPanel.canChooseDirectories = false         openPanel.allowsMultipleSelection = false         openPanel.begin { response in             if response == .OK {                 self.url = openPanel.url             }         }     } should I file a bug? should I reinstall xcode?
1
0
387
May ’22
Stuck
I have a big problem with an AI app. It's supposed to give me a color according to the text entered into a TextField. But every time it gives me the same output. I'm new in developing, and I know it must be a tiny bug but I just couldn't find out why. Should I just ... paste all of my code here? I can't upload a .zip :(
6
0
474
May ’22
Issue with split(or at least I think so)
I'm trying to make an app that'll suggest a color based on a keyword the user inputs. I store prediction from the model to a [String: Double] array and then compute the output color. However, I'm stuck on two strange errors. Here's my code: extension Array where Element == [String: Double]{ func average() -> RGBList{ var returnValue = (r: 0, g: 0, b: 0) var r = 0 var g = 0 var b = 0 for key in self{ r = Int(key[0].split(",")[0]) * key[1] ... } ... } }
3
0
1.1k
May ’22
Build input file not found
I know there should be a easy solution to this mess but I JUST CAN'T FIND IT AHHHHHHHHHH     cd ...... error: Build input file cannot be found: '/Users/***/Library/Developer/Xcode/DerivedData/ColorLibrary-hakdntgphjogwuawcvuxomfrjzex/Build/Products/Debug-iphonesimulator/ColorKit iOS.app/ColorKit iOS' (in target 'ColorKit iOS' from project 'ColorLibrary')
2
0
550
May ’22
WebKit Loading problem
I'm tired of opening up safari to open developer.apple.com so I'm trying to embed the website into an app, but sth is definitely wrong. It's been loading for ten mins and is still white. here's the code import SwiftUI import WebKit import UIKit struct WebViewPage : UIViewRepresentable { func makeUIView(context: Context) -> WKWebView { return WKWebView() } func updateUIView(_ uiView: WKWebView, context: Context) { let req = URLRequest(url: URL(string:"developer.apple.com")!) uiView.load(req) } } #if DEBUG struct WebViewPage_Previews : PreviewProvider { static var previews: some View { WebViewPage() } } #endif app delegate: import SwiftUI @main struct Developer_WebpageApp: App { var body: some Scene { WindowGroup { WebViewPage() } } }
0
0
330
Apr ’22