I'm only really beginning IOS development but have a few years dev of ASP.net through C#. To be honest I've never had a real need to understand delegates / events etc. before, I know that I'm using them when programming web.forms but a lot of the functionality is taken care of by the framework, behind the scenes.
So now that I'm developing in IOS I'm forced to try to understand how they function (I'm presuming here that the theory of delegates / events is the same across languages, maybe I'm wrong). Anyway, the following line of code in IOS:
if ([self.delegate respondsToSelector:@selector(startImporting:)])
{
[self.delegate startImporting:self];
}
Am I right in thinking that, in pseudo code, it means something along the lines of:
If the method/class calling this method has a method in it called 'startImporting' then call the method 'startImporting' within the calling class.
Hope that's clear. If that's the case then would it essentially be the same as having a static method in C# that you could call with something like:
myImportClass.startImporting();
Presumably not, or that's how it would be done. So, am I missing the whole point of delegates, their benefits etc? I've read what they are over and over and while it makes sense, it never clicks, I never (in web forms anyway) have really seen the benefit of using them.
This becomes increasingly important as I'm moving to using lambda expressions in .net and they're closely linked to delegates in C# so while I can just start using them, I'd prefer to know why and what benefit delegates actually are.