In my app i am sending a request to server .
The request is in some other class-called requestClass, and is being called from the main view class. (i am using cocos2d).
My question is, how would i informed the main class (from the requestClass ) that the operation is done ?
When it finish the request-its callback is in its own class(requestClass) and the NSLog is done IN the requestClass .
i dont think NSNotification is the right way
requestClass is like :
[NSURLConnection
sendAsynchronousRequest:request
queue:[[NSOperationQueue alloc] init]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error)
{
if ([data length] >0 && error == nil)
{
**// HOW SHOULD I INFORM THE CLASS THAT CALL ME NOW ???**
}
else if ([data length] == 0 && error == nil)
{
NSLog(@"Nothing ");
}
else if (error != nil){
NSLog(@"Error = %@", error);
}
}];
OK, to write a delegate protocol…
Assuming your connection file is called MyRequestClass.
In MyRequestClass.h…
Then in MyRequestClass.h
Then in whichever class you want…
In SomeOtherClass.h
In someOtherClass.m
… and make sure to write the delegate function too…