i'm getting lost on the use of delegates. ok they are used to pass values between objects, let's say ClassA needs to pass values to ClassB, we should use a delegate ( if i got that at least ).
let's say i have a ViewControllerA which has a textfield and a button, and a ViewControllerB which has a label. To pass the data saved from the textfield in the VControllerA to the VControllerB i can use a delegate...
let's see the first class
//ViewControllerA
#import <UIKit/UIKit.h>
@interface ViewControllerA : UIViewController {
IBOutlet UITextField *tf_text;
IBOutlet UIButton *but_add;
}
@property (nonatomic, retain) IBOutlet UITextField *tf_text;
@property (nonatomic, retain) IBOutlet UIButton *but_add;
-(IBAction)addAction:(id)sender;
@end
ok this is the other
//ViewControllerB
#import "ViewControllerA.h"
@interface ViewControllerB : ViewController {
IBOutlet UILabel *_label;
}
@property (nonatomic, retain) IBOutlet UILabel *_label;
@end
ok now i start to get lost. what will be the correct way to use this protocol ? let's say i want to do it as a new file controllerADelegate.h
how should i pass data?
i'm getting crazy about it, i seen many online tutorial but i still can't really get how to use it