Как я могу получить доступ к свойству ViewController из другого класса?
(ViewController был создан XCode)
доступ к собственности другого класса
это код ViewController.h:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
@interface ViewController : UIViewController{
AppDelegate *appDelegate; //il delegate disponibile per tutta la classe
int numPag; //indice array (sulle pagine html da visualizzare)
NSString *path;
NSURL *baseURL;
NSString *file;
NSString *contentFile;
}
- (IBAction)sottrai:(id)sender;
- (IBAction)aggiungi:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *valore;
@property (strong, nonatomic) IBOutlet UIWebView *web;
@end
спасибо!
[EDIT]
Я использую Xcode 4.3.2 и код AppDelegate.m не найти что-то вроде:
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
Теперь я ставлю в метод didFinishLaunchingWithOptions: (в AppDelegate.m) этот код:
viewController = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[viewController.web loadHTMLString:contentFile baseURL:baseURL];
добавление в файл AppDelegate.h переменную ViewController:
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
NSArray *pageInItalian;
NSArray *pageInEnglish;
UIViewController *viewController;
}
@property (strong, nonatomic) NSArray *pageInLanguage;
@property (strong, nonatomic) UIWindow *window;
@end
Я сделал это правильно? ошибка: свойство «веб» не найден на объект типа 'UIViewController *
как я беру экземпляр ViewController? Контроллер view был создан XCode в коде. Могу ли я создать экземпляр? – Antilope
Взгляните на мое редактирование. –
Я также добавил (а) изменение – Antilope