Post

Replies

Boosts

Views

Activity

What is the error?
What is the error in this code? @main struct CollectionManagerApp: App {     init() {         do {             var bo: ObjCBool = true             let library = try FileManager().url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appending(path: "CollectionManager")             let database = library.appendingPathComponent("DataBase.plist")             if !FileManager().fileExists(atPath: library.absoluteString) {                 try FileManager().createDirectory(at: library, withIntermediateDirectories: false)             }             if !FileManager().fileExists(atPath: database.absoluteString) {                 FileManager().createFile(atPath: database.absoluteString, contents: nil)                 print("OK")             }         } catch {             print("Init Error:  \(error)\nEND")         }     }     var body: some Scene {         WindowGroup {             ContentView()         }     } } The error: Init Error:  Error Domain=NSCocoaErrorDomain Code=516 "The file “CollectionManager” couldn’t be saved in the folder “Application Support” because a file with the same name already exists." UserInfo={NSFilePath=/Users/gattino09/Library/Application Support/CollectionManager, NSUnderlyingError=0x600003ba0150 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}} END
0
0
571
Jan ’23
JSON Array
can I create a json array without key? An example: {     [         {             "id":1,             "name":"Otto Matic",             "icon":"",             "developer":"Pangea Software"         },         {             "id":2,             "name":"Minecraft",             "icon":"",             "developer":"Mojang"         }     ] }
1
0
415
Jun ’22
Is there a more simple way to create a directory in swift 5?
let applicationSupport = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0])     let launcherdir = applicationSupport.appendingPathComponent("MyApp") do { try FileManager.default.createDirectory(atPath: launcherdir!.path, withIntermediateDirectories: true, attributes: nil)                 } catch {                     print(error)                 }
3
0
1.1k
May ’22