ff10
ff10

Reputation: 3147

Import subclasses of a protocol

The following class structure is given:

clprotocol.h
cla
cla1
cla2
cla3
clb
clb1
clb2
clb3

foo.h

All classes implement the clprotocol. clxn are subclasses ob clx.

I would like to inform foo.h of the existence of all classes which implement clprotocol.h. The straight forward way would be of course to import all headers in foo.h. But especially with large class clusters this is a very tedious task. Is there a more elegant way, also regarding the fact that if have to import this cluster in other classes, too?

I feel like I am missing some basic principle here, but I can't put my finger on it...

Upvotes: 0

Views: 66

Answers (1)

jrturton
jrturton

Reputation: 119272

Declare your variables as id<CLProtocol> instead of CLA* or similar. If all you care about is that they conform to the protocol, that is all you need.

Upvotes: 2

Related Questions