So I’m building a system in which there is a server object, and it generates Uploader objects. Both are defined as protocols/interfaces, whichever term you prefer. The Server object has a method which generates an Uploader and returns it, with the following signature:
- (id<Uploader>)generateUploader;
The Uploader needs to contain a reference back to the Server which created it, because it needs a reference to a Server to get the password from my keychain wrapper. So, it contains a method which returns its parent Server:
- (id<VayprServer>)parentServer;
Of course, this creates a circular dependency between the two protocols. Any ideas on how to fix this?
Thanks!
Billy
To break the dependency, like all circular dependencies, you gotta forward-declare stuff in the .hs. In particular:
and
and
and
This way, the two .ms will see things declared in the correct order.