Ios 如何使每个循环都加倍工作?
我正在尝试为带有SwiftUI的apple watch定制discord客户端。我必须使用double for each循环来显示标题频道(父频道)和正常文本聊天(子频道)。当我运行代码时,我只得到for-each循环的结果。有人知道如何解决这个问题吗Ios 如何使每个循环都加倍工作?,ios,swift,xcode,swiftui,Ios,Swift,Xcode,Swiftui,我正在尝试为带有SwiftUI的apple watch定制discord客户端。我必须使用double for each循环来显示标题频道(父频道)和正常文本聊天(子频道)。当我运行代码时,我只得到for-each循环的结果。有人知道如何解决这个问题吗 struct ChannelsView: View { var serverId: String var body: some View { List{ ForEach(Network
struct ChannelsView: View {
var serverId: String
var body: some View {
List{
ForEach(NetworkHandler.parentChannels){parentChannel in
Text(parentChannel.name)
.font(.headline)
ForEach(parentChannel.childChannels){channel in
NavigationLink(destination: MessagesContentView(channelId: channel.id, channelName: channel.name)){
ChannelView(name: channel.name)
}
}
}
}
.navigationBarTitle("Channels")
.onAppear(){
NetworkHandler.getChannels(serverId: self.serverId)
}
}
}
谢谢double在哪里?@koen我曾经为每个循环使用过。如果我正确理解了你的目标,你需要一节(s)啊,这很有道理,我想他是说作为一个值,
double
。@Asperi yes节