gpt4 book ai didi

generics - ForEach中的内容不应该符合View吗

转载 作者:行者123 更新时间:2023-12-04 07:56:10 25 4
gpt4 key购买 nike

不应该是ContentForEach符合 View ?
这里 ForEach 定义为
enter image description here
现在我真的很确定它应该声明为:

struct ForEach<Data, ID, Content> where Data: RandomAccessCollection, ID: Hashable,    Content: View
所以我一直在寻找,发现了这个:
enter image description here
所以现在我的问题是:
泛型可以在管道中的其他地方定义还是文档中的错误
提前致谢。

最佳答案

这是一个使通用的扩展 ForEach is-a View以内容作为 View

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ForEach : View where Content : View {

/// The type of view representing the body of this view.
///
/// When you create a custom view, Swift infers this type from your
/// implementation of the required `body` property.
public typealias Body = Never
}

关于generics - ForEach中的内容不应该符合View吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66690130/

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