Я пытаюсь получить доступ к некоторым вещам из другого контроллера просмотра (iOS).
У меня есть ViewController.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextFieldDelegate> {
...
}
@end
ViewController.m:
#import "ViewController.h"
#import "ViewController2.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
ViewController2.someVar = @"cakes"; // this is where I'm trying to set something in vc2
}
ViewController2.h:
#import <UIKit/UIKit.h>
@interface ViewController2 : UIViewController <UITableViewDataSource, UITableViewDelegate, UISearchDisplayDelegate>
{
...
}
@property (nonatomic, copy) NSString *someVar;
@end
ViewController2.m:
#import "ViewController2.h"
@interface ViewController2 ()
@end
@implementation ViewController2
@synthesize someVar;
etc.
Но в строке, где я пытаюсь получить доступ к этой переменной, возникает следующая ошибка:
Свойство «someVar» не найдено в объекте типа «ViewController2».
Каким образом я могу получить доступ к этому другому контроллеру представления?