我正在使用AudioVideoBridging框架。我也在Swift编写我的应用程序。 我对这一切都很陌生。
我查找了一些其他协议转换并遵循相同的格式,但我收到了编译错误。
这是目标c协议
- (void)didAddRemoteEntity:(AVB17221Entity *)newEntity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didRemoveRemoteEntity:(AVB17221Entity *)oldEntity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didRediscoverRemoteEntity:(AVB17221Entity *)entity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didUpdateRemoteEntity:(AVB17221Entity *)entity changedProperties:(AVB17221EntityPropertyChanged)changedProperties on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didAddLocalEntity:(AVB17221Entity *)newEntity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didRemoveLocalEntity:(AVB17221Entity *)oldEntity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didRediscoverLocalEntity:(AVB17221Entity *)entity on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
- (void)didUpdateLocalEntity:(AVB17221Entity *)entity changedProperties:(AVB17221EntityPropertyChanged)changedProperties on17221EntityDiscovery:(AVB17221EntityDiscovery *)entityDiscovery;
这是我的转换:
func didAddRemoteEntity (newEntity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didRemoveRemoteEntity (oldEntity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didRediscoverRemoteEntity (entity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didUpdateRemoteEntity (entity: AVB17221Entity!, changedProperties changedProperties : AVB17221EntityPropertyChanged!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didAddLocalEntity (newEntity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didRemoveLocalEntity(oldEntity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didRediscoverLocalEntity(entity: AVB17221Entity!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didUpdateLocalEntity (entity: AVB17221Entity!, changedProperties changedProperties : AVB17221EntityPropertyChanged!, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
这是我的班级声明:
class MainWindowController : NSObject, AVB17221EntityDiscoveryDelegate
以下是编译器的说法:
类型'MainWindowController'不符合协议'AVB17221EntityDiscoveryDelegate'
任何帮助都将非常感谢....
答案 0 :(得分:0)
我在Apple Developer论坛上得到了答案:
将行更改为:
func didUpdateRemoteEntity (entity: AVB17221Entity!, changedProperties : AVB17221EntityPropertyChanged, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
func didUpdateLocalEntity (entity: AVB17221Entity!, changedProperties : AVB17221EntityPropertyChanged, on17221EntityDiscovery entityDiscovery: AVB17221EntityDiscovery!){}
AVB17221EntityPropertyChanged不是引用类型,因此您不应将其设为可选项。