gpt4 book ai didi

objective-c - 没有协议(protocol)的 iOS 委托(delegate)?

转载 作者:行者123 更新时间:2023-11-28 06:26:15 24 4
gpt4 key购买 nike

Delegation 状态的 Apple 文档:

In both Swift and Objective-C delegation is often expressed with a protocol that defines the interaction and a conforming delegate property

我不确定是否有任何其他方法可以创建不“必须”涉及协议(protocol)的委托(delegate)。在 Swift 或 Objective-C 中是否有另一种不涉及协议(protocol)的表达委托(delegate)的方式?

最佳答案

委托(delegate)不必遵守协议(protocol)。您可以编写实现代码,但这是不好的做法。

我认为 apple 是在说这是通常的处理方式。您不必使用协议(protocol)...但如果您想保持灵 active ,则应该使用协议(protocol)。

委托(delegate)本质上是要求别人为您做某事。如果您执行契约(Contract),那么他们更有可能为您执行。

关于objective-c - 没有协议(protocol)的 iOS 委托(delegate)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41781274/

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