On Callback
On Iphone
File A:
@protocol servicedelegate
-(void)taskCompleted:(NSDcitionary*) dict;
@end
-(void) performtask
callback=@”taskCompleted:”;
[(id)delegate performSelector:NSSelectorFromString(callback) withObject:data];
File B:
-(void) taskcompleted:(NSDictionary*)dict
{
//don something when File A fisnihed the taskcompleted and have the data
// this callback on File B will be awaken from File A’s delegate function
}
The question How does Android implement the above, File A waiting to getting the data, and nobody knows how long, but once finished, File B would awaken by the delegate callback function of taskcompleted.
There are a couple different ways:
I’m a fan of AsyncTask myself, but they require more boilerplate. Handlers can often be simpler.