Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

namanhams

macrumors regular
Original poster
Hi everyone,

I've used delegate many times, but i've just realized something that i dont know why it can be like that.
Let say a class A has a delegate which implements a protocol B.

- Class A :
@interface A : NSObject {
id<B> delegate;
}
@end

- Protocol B :
@protocol B
- object : (A *) a doSomething : (SomeClass *) s
@end

Because A references B, B references A, I dont know how can i define both things. I know it's possible (the UITableView and UITableViewDelegate is an example), but i dont know how. I've tried to go arround this problem but the compiler keeps giving me errors.

Thanks for reading my post.
 
Before the @interface on your class, put @protocol B; - this just makes the compiler aware of the protocol at that point, similar to how you can use @class.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.