小编Vla*_*lav的帖子

如何链接结构?需要优化性能

我正在尝试优化我的代码以最小化不必要信息的下载大小。

我的目标是将 testData 数组中的项目链接到另一个结构中调用方法。

下面是一个例子:

struct Recipe: Identifiable, Hashable, Codable {
    @DocumentID var id: String? = UUID().uuidString
    var title: String
    var description: String
    var imageName: String
}
let testData = [
    Recipe(title: "Recipe1", description: "Description1", imageName: "Image1"
    Recipe(title: "Recipe2", description: "Description2", imageName: "Image2"
    Recipe(title: "Recipe3", description: "Description3", imageName: "Image3"
]

// Then another struct, which needs to be linked to members of the array above
// Code below is incorrect, will not work
struct CommentSection {
    var recipe: Recipe // …
Run Code Online (Sandbox Code Playgroud)

database arrays struct swift

6
推荐指数
1
解决办法
64
查看次数

标签 统计

arrays ×1

database ×1

struct ×1

swift ×1