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