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

dws90

macrumors regular
Jan 16, 2008
122
0
There's a bit of flexibility on how you want to structure things, but the vast majority of the time, the delegate is held as an instance variable, and you just pass a message to it like you would any other object.

So, you might declare the instance variable
id <BigRedButtonDelegate> _delegate;

(where BigRedButtonDelegate is a protocol you define)

then, you just call make a call like:
[_delegate somebodyDidPressTheBigRedButton];
 

misee

macrumors member
Jul 4, 2010
65
0
If you have methods that your delegate can implement optionally, you can also use informal protocols (or the @optional in a protocol interface) and then do something like this:
Code:
if ([delegate respondsToSelector:@selector(infoForMyClass:))
    [delegate infoForMyClass:self];
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
This question is confusing. The delegate is just an object, you message it the same as you would with any other object method pair. The only real important thing to decide is if you want to check to see that the object responds to the method, or if the object "says" it conforms to the delegate protocol.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.