Skip to content

Constantly returning empty array #47

@uguraltinsoy

Description

@uguraltinsoy

Constantly returning empty array where am I going wrong

import SwiftUI
import WebDAV

public struct SimpleAccount: WebDAVAccount {
    public var username: String?
    public var baseURL: String?
}

struct ContentView: View {
    let webDav = WebDAV()
    let account = SimpleAccount(username: "<username>", baseURL: "<baseurl>")
    
    var body: some View {
        VStack(content: {
            Button(action: {
                print("Get...")
                getData()
            }, label: {
                Text("GET DATA")
            })
        })
        
    }
    
    func getData() {
        webDav.listFiles(atPath: "/", account: account, password: "<password>", completion: { files, error in
            /*if let error = error {
                print("Error listing files: \(error)")
                return
            }*/
            print("Error: \(error)")
            print("Data: \(files)")
            
            /*if let files = files {
                for file in files {
                    print("Name: \(file.name), Type: \(file.isDirectory ? "Directory" : "File")")
                }
            }*/
        })
    }
}

#Preview { ContentView() }

export:

Get...
Error: nil
Data: Optional([])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions