Skip to first unread message


Oct 21, 2009, 12:47:30 PM10/21/09
to Midwest iPhone SDK Developers

In order to work with async calls, like downloading a lot of data in
chunks, and then telling the caller that the download is done it is
necessary to make a callback. This is extremely easy in JavaScript by
passing in a callback function. In .NET you would publish an event
from the worker and subscribe to that event from the caller and raise
the event to tell the caller when the action has occurred. In
Objective-C I have learned this is done very differently with
delegates. It took me a while to wrap my head around it.

I put together a sample for an iPhone app which does what you need to
do to make a callback/delegate. It is actually pretty easy. You use
the @prototype and @optional directives to define method signatures
which act as delegates so that when you try calling them in your code
that you do not get compiler warnings.

The sample project is uploaded to this group and is linked at the top
of this message.

I found the following post on to be most useful.
Reply all
Reply to author
0 new messages