如何解决Swift:未调用Twilio委托函数
请原谅我的斯威夫特贵气。
我正在使用Twilio的VideoCall框架,想知道为什么我的RoomDelegate函数没有被调用。
struct AppHome: View {
var roomDelegate = myRoomDelegate()
当我连接到房间时,我进入了roomDelegate:
let connectOptions = ConnectOptions(token: self.accesstoken) { (builder) in
builder.roomName = self.call.call_api.room_name
builder.audioTracks = [self.roomDelegate.localAudioTrack!]
}
let room = TwilioVideoSDK.connect(options: connectOptions,delegate: self.roomDelegate)
我的roomDelegate类具有:
class myRoomDelegate: NSObject,RoomDelegate {
...
func roomDidConnect(room: Room) {
print("Delegate " + #function)
}
func roomDiddisconnect(room: Room,error: Error?) {
print("Delegate " + #function)
}
func roomDidFailToConnect(room: Room,error: Error) {
print("Delegate " + #function)
}
func roomIsReconnecting(room: Room,error: Error) {
print("Delegate " + #function)
}
func roomDidReconnect(room: Room) {
print("Delegate " + #function)
}
func participantDidConnect(room: Room,participant: RemoteParticipant) {
print("Delegate " + #function)
}
func participantDiddisconnect(room: Room,participant: RemoteParticipant) {
print("Delegate " + #function)
}
}
我发现的所有委托示例都使用self
,所以我试图了解我在做的事情是否有效,如果有效,为什么我的委托回调不起作用?
解决方法
在我看来您对类型有疑问,因此将结构更改为class并尝试运行:
class AppHome: View {
var roomDelegate = myRoomDelegate()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。