什么是代表?
我正在目标 c 上编写一些东西,但我仍然不明白,我根本不知道/理解委托是什么。
也许因为我的主要编程语言是 C++ 和 Java...不知道。
我在网上搜索寻找英文解释,但是,似乎我不会说英语:)
I was coding some stuff on objetive c.. but I still dont get it, I dont know/understand what a delegate is at all.
Maybe cuz my main programming language is C++ and Java... dont know.
I searched the web looking for an ENGLISH explanation, but, seems like I dont speak english :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
委托是一个对象的实例,它以面向对象的方式实现了一堆 C 程序员所谓的回调。像大多数新概念一样,它实际上只是一个旧约定的重命名和混淆。
维基百科上有一些很好的示例。
A delegate is an instance of an object that implements a bunch of what C programmers call callbacks, but in an object-oriented way. Like most new concepts, it is really just an old convention renamed and obfuscated.
There are some nice examples here on wikipedia.
在 Objective-C 中,委托是一个符合特定协议的对象,另一个对象可以依赖它来实现特定的功能。这与许多其他语言中的委托是一个不同的概念,并且可能会令人困惑,因为术语是相同的。
当我开始使用 Objective-C 编程时,我发现这篇文章非常有用:
http://developer.apple.com/mac/library/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html
In Objective-C, a delegate is an object that conforms to a specific protocol, that another object can rely on for specific functionality. It's a different concept to delegation in lots of other languages, and it can get confusing because the terminology is the same.
Here's an article I found rather useful when I started programming in Objective-C:
http://developer.apple.com/mac/library/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html