I have the following code to start my own Cocoa HTTP Server. In order to manually handle the responses I have created my custom HTTPConnection
class named PictureHTTPConnection
self.httpServer = [[HTTPServer alloc]init];
self.httpServer.type = @"_http._tcp.";
self.httpServer.name = @"MyBonjour Name";
self.httpServer.connectionClass = [PictureHTTPConnection class];
The problem here is that the PictureHTTPConnection
class needs some information in order to handle the HTTP connections. However, I only provide the class and therefore I don't have a reference to the instance. I could do something with global data but this is not very good programming practise.
The best way I can think of is setting the PictureHTTPConnection
's delegate to the UIApplicationDelegate
so that it can answer any callbacks. :-(