gpt4 book ai didi

SwiftyDropbox 仅列出文件夹

转载 作者:搜寻专家 更新时间:2023-10-31 08:17:25 25 4
gpt4 key购买 nike

我在我的 iOS 应用程序中使用 SwiftyDropbox SDK,我试图仅在我的应用程序中列出文件夹,然后用户可以选择一个文件夹(而不是一个文件)。

ViewController => viewDidLoad

override func viewDidLoad() {
super.viewDidLoad()

guard let dropboxClient = DropboxClientsManager.authorizedClient else{
return
}

let listFolders = dropboxClient.files.listFolder(path: "")
listFolders.response{ response, error in
guard let result = response else{
return
}

for entry in result.entries{
print(entry)
}
}
// Do any additional setup after loading the view, typically from a nib.
}

条目是>

  { 
id = "id:0GMPvYwuVEAAAAAAAAAABw";
name = "Folder A";
"path_display" = "/Folder A";
"path_lower" = "/folder a";
}

我怎样才能找到这个条目是文件夹,它是否包含子文件夹?

最佳答案

您可以像这样在 result.entries for 循环中转换每个 entry

override func viewDidLoad() {
super.viewDidLoad()

guard let dropboxClient = DropboxClientsManager.authorizedClient else{
return
}

for entry in result.entries{
guard let file = entry as? Files.FolderMetadata else{
return
}

// only folders
print(entry)

// ********* or
gurad let entry is Files.FolderMetadata else{
return
}

// only folders
print(entry)
}
}

关于SwiftyDropbox 仅列出文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45321080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com