Can anyone tell me where I'm going wrong here please. I have created an NSobject called BeaconData. The header file is:
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BeaconData : NSObject
@property (nonatomic, strong) NSMutableArray * jsonArray;
@property (nonatomic, retain) NSString * bMajor;
@property (nonatomic, retain) NSString * bMinor;
@property (nonatomic, retain) NSString * bUUID;
-(void) getData;
@end
The implementation file is then:
#import "BeaconData.h"
#define getDataURL @"http://www.eventav.biz/websitebeacons/library/json/files/beacons.txt"
@implementation BeaconData
@synthesize jsonArray, bUUID, bMajor, bMinor;
//Retrieve data
-(void) getData
{
extern NSString * bUUID;
extern NSString * bMajor;
extern NSString * bMinor;
NSURL * url = [NSURL URLWithString:getDataURL];
NSData * data = [NSData dataWithContentsOfURL:url];
jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
//Loop through Json Array
for (int i = 0; i < jsonArray.count; i++)
{
bUUID = [[jsonArray objectAtIndex:i] objectForKey:@"i_uuid"];
bMajor = [[jsonArray objectAtIndex:i] objectForKey:@"i_major"];
bMinor = [[jsonArray objectAtIndex:i] objectForKey:@"i_minor"];
}
}
@end
Next I try to call the Global variable bMajor in the main viewController.m file and print it out - just to see if it works, like this:
- (void)viewDidLoad {
[super viewDidLoad];
extern NSString * bMajor;
NSInteger beaconMajorInt = [bMajor integerValue];
NSLog (@"Beacon bMajor is %li", (long)beaconMajorInt);
But all I get is the following error:
Undefined symbols for architecture x86_64: "_bMajor", referenced from: -[ViewController viewDidLoad] in ViewController.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)