I have 2 class in my program first class is class1 and second class is class2.I want create and initialize global variable in class 1 and to use in class 2 but compiler give me this ERROR XD :
Undefined symbols for architecture i386:
"_saeid", referenced from:
-[class2 viewDidLoad] in class2.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I create global variable in class1 and run that in class2 with this way but don't work:
class1.h
extern int saeid; // this is global variable
@interface class1 : UITableViewController<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) IBOutlet UITableView *table;
@end
class1.m
#import "class1.h"
#import "class2.h"
@implementation class1
{
int saeid;
}
@synthesize table;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int x = (indexPath.row)+1;
saeid = x; //initialize global variable
NSLog(@"X & SAEID: %d & %d",x,saeid);
}
class2.h
#import "class1.h"
@interface class2 : UIViewController<UIScrollViewDelegate>
{
}
@end
class2.m
#import "class2.h"
@implementation class2
{
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Saeid in class2 : %d",saeid);
}