This is the prototype:
- (void)startDownloadingDataOfType:(NSString *) type fromURL:(NSURL *) url delegate:(id <GetURLAsyncDelegate>) delegate;
There is a delegate set up with methods such as URLDidFinishDownloading and so on. However I stil don’t totally understand delegates – I get their point, but I don’t really know how to use them.
This function seems to contain a parameter to pass IN a delegate, but surely I want to extract one?
In the class where I want to call this function I essentially want to be able to trigger a method when the URL has finished it’s download. What is the syntax for using this kind of function in a class?
Passing the delegate to the prototype will cause the method to be called on the supplied delegate.
If you want the method (URLDidFinishDownloading) to be called when the download is complete in the class you called it from, implement the delegate in that class and specify the URLDidFinishDownloading method.
Something like below – (note: my obj-c isn’t the greatest, but hopefully you get the idea)