I’m making an app where I have different things: images, videos,a viewController(.h and .m) and another file (let’s call it file2, with .h and .m too)
The problem is that I want to use a string from the viewController.h in file2.m, and I can’t. I tried this:
// ViewController.h
{
NSString *string;
}
@property (nonatomic, retain) NSString *string;
//ViewController.m
@synthesize string;
// file2.m
#import"viewController.h"
- (IBAction)changestring:(id)sender {
string = @"something";
}
So Xcode returns to me an error when I try to change the string. What am I doing wrong?
Thank you!
Add a property for your string in viewController.h outside the interface like this
and synthesize it in
So that you can access that string in other files where you imported your viewController.h
EDIT:
create an object for your viewController.h in file2 and access like this