Я хочу распечатать vc1.string1 из vc2.
В данный момент на консоли отображается:
vc1.string1 (null)
Когда яЯ не использовал раскадровку. Я обращался к переменной vc1 следующим образом:
AppDelegate *appDelegate = [(AppDelegate *)[UIApplication sharedApplication]delegate];
NSLog(@"vc1.string1 %@", appDelegate.viewController.string1);
Но я не знаю, как получить доступ к vc1.string при использовании раскадровки.
Помогите, пожалуйста, спасибо.
PS Вот ссылка моего проекта: 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