What is a delegate?
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 :)
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.
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
精彩评论