When using asynchronous calls, you are waiting for a callback. This basically means that you ask the class to start doing something, and when it does, it should execute the method of your choice.
A good example of this is Apple's own NSUrlConnection class. You provide this class to the delegate. This is basically an object that the NSUrlConnection class will execute methods as needed.
So,
NSURLRequest * req = [NSURLRequest requestWithURL: self.url];
self.downloadConnection = [NSURLConnection connectionWithRequest: req
delegate: self];
[self.downloadConnection start];
NSUrlConnection self.url .
, , , ,
- (void) connectionDidFinishLoading: (NSURLConnection *) connection
{
}
. @protocol , . ,
- (void)userFetched:(User *)user
restLibrary ,
[restLibrary getUser:@"tom" delegate:self]
userFetched.
getUser restLibrary ( , NSUrlConnection User), userFetched .
..
?