After asking some questions, I learned how to send orders from one view controller to another and managed to write the code its working but nothing happens...
In my
Try to add the following method to your sayfa23's implementation:
- (void)viewDidLoad
{
vc1 = [[sayfa1 alloc] init];
vc1.delegate = self;
}
and remove vc1.delegate = self; from your dealWithButton1 method.
Edit: You have to understand that the method dealWithButton1 is never getting called because you are never sending the message to the object. Therefore, you are never setting the delegate of vc1. It is a good point to do some setup using the viewDidLoad method, which is called when the view is loaded. There you can alloc init (create an instance of) the sayfa1 class, and assign it to your property vc1. After you have allocated the object you can send messages to it. You can set the delegate then.
sayfa23.h
#import
#import "sayfa1.h"
@interface sayfa23 : UIViewController
{
IBOutlet UILabel *label;
}
@property (nonatomic, strong) sayfa1 *vc1 ;
@end
sayfa23.m
#import "sayfa23.h"
#import "sayfa1.h"
@interface sayfa23 ()
@end
@implementation sayfa23
@synthesize vc1;
- (void)viewDidLoad
{
vc1 = [[sayfa1 alloc] init];
vc1.delegate = self;
}
- (void)dealWithButton1
{
int random_num;
random_num = (arc4random() % 5 - 1) + 1;
if (random_num == 1)
{
label.text = @"hello1";
}
else if (random_num == 2)
label.text = @"hello2";
else if (random_num == 3)
label.text = @"hello3";
else if (random_num == 4)
label.text = @"hello4";
}
@end