I want to print out vc1.string1 from vc2.
Currently console's showing:
vc1.string1 (null)
When I was not using storyboard I accessed vc1 variable like this:
AppDelegate *appDelegate = [(AppDelegate *)[UIApplication sharedApplication]delegate];
NSLog(@"vc1.string1 %@", appDelegate.viewController.string1);
But I don't know how to access vc1.string when I'm using storyboard.
Help please thanks.
P.S. Here's the link of my project: http://dl.dropbox.com/u/12439052/AccessDiffClass.zip
//ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
NSString *string1;
}
@property (nonatomic, strong) NSString *string1;
@end
#import "ViewController.h"
@implementation ViewController
@synthesize string1;
-(void)viewDidLoad {
string1 = @"String One";
NSLog(@"string1 %@", string1);
}
@end
VC2:
//ViewController2.h
#import <UIKit/UIKit.h>
@class ViewController;
@interface ViewController2 : UIViewController {
ViewController *vc1;
}
@property (nonatomic, strong) ViewController *vc1;
@end
#import "ViewController2.h"
#import "ViewController.h"
@implementation ViewController2
@synthesize vc1;
-(void)viewDidLoad {
NSLog(@"vc1.string1 %@", vc1.string1);
}
@end