please i got errors when i try to read the content of a variable in view2 which was initialized in view1, i explain :
view1 is named RechercherViewController
view2 is named StationsSurLaCarteViewController
RechercherViewController.h :
@property (nonatomic,copy) NSString *typeCarburantChoisi;
RechercherViewController.m :
@synthesize typeCarburantChoisi;
StationsSurLaCarteViewController.h
#import "RechercherViewController.h"
@interface StationsSurLaCarteViewController : UIViewController {
IBOutlet AideStationsSurLaCarteViewController *aideStationsSurLaCarteViewController;
IBOutlet UITextField *textField;
}
@end
StationsSurLaCarteViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
textField.text=RechercherViewController.typeCarburantChoisi;
}
when building the app, i got actually two errors :
error: expected specifier-qualifier-list before 'StationsSurLaCarteViewController'
and
error: accessing unknown 'typeCarburantChoisi' class method
thx for help 🙂
First of all you have defined an instance property
typeCarburantChoisibut in yourStationsSurLaCarteViewController.mcode you are trying to access kind of a class property (btw, there is no such thing in Objective-C). You will instead need a reference to yourRechercherViewControllerinstance and ask it for the property – this will resolve the second compiler error.Regarding the first error I am not really sure what happened here. Maybe you have an error in your
RechercherViewController.hfile?In any case, you should rather not import the interface file into
StationsSurLaCarteViewController.h. Instead, useand import the full declaration in your implementation file
StationsSurLaCarteViewController.monly.Also, did you mix up
AideStationsSurLaCarteViewControllerandRechercherViewControllerin your example?