Question about singletons and invoked methods
I've created a singleton to perform some server requests. However for some requests I need to get the results back. What's the best way to get them from the invoking classes (using the singleton) ?
This is the invoked method by the singleton when the data are received. Should I pass a target and selec开发者_开发技巧tor to the singleton to perform a method of the invoker class ?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// do something with the data
//invoking passed selector here ?
// receivedData is declared as a method instance elsewhere
NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
// release the connection, and the data object
[connection release];
[receivedData release];
}
thanks
Passing local notification inside the delegate would be better than receiving the selector of the invoker class. That local notification can handle by anyone who registers it and thus minimize the dependency.
精彩评论