Trying to store all RSSI values in an NSMutablearray during the course of run time then finally output to the console. Have changed the value of x to 20000 to see if there are any changes in the value of the RSSI...unfortunately, no changes- Xcode reports 20000 values of the RSSI read in at the start of the code (not sure if this is an issue with sampling or ?). Any help would be greatly appreciated.
rssiArray = [[NSMutableArray alloc] init];
long newBeacon = 0;
if (beacon.rssi == newBeacon)
{
newBeacon = beacon.rssi;
}
else
{
for (int x = 0; x < 1; x++) {
[rssiArray addObject:[NSString stringWithFormat:@"%d", x]];
[rssiArray addObject:@(beacon.rssi)];
}
}
//Send array to console
NSLog (@"%@", [self rssiArray]);
The array is synthesized at the top of this same file like this:
#import "ViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "DetailViewController.h"
@interface ViewController ()
{
}
@end
@implementation ViewController
@synthesize rssiArray;
The array is also defined in the ViewController.h here:
//array for storing RSSI values
@property (strong, nonatomic) NSMutableArray *rssiArray;
@PaulW
So...
initialize the array in ViewController.m like this:
- (void)viewDidLoad { [super viewDidLoad]; rssiArray = [[NSMutableArray alloc] initWithObjects:nil]; }
Paste the following code into didRangeBeacons method within the AppDelegate.m like so...
for (int x = 0; x < 500; x++) { [rssiArray addObject:[NSString stringWithFormat:@"%d", x]]; [rssiArray addObject:@(NOTSUREWHATGOESHERE???..WANT TO STORE RSSI)]; } //Send array to console NSLog (@"%@", [self rssiArray]);
A simplistic approach that just stores rssi would be -
The reason that I say this is approach simplistic is that it simply stores rssi values into an array, regardless of which beacon they came from - as long as you are only ranging a single beacon at a time this won't be a problem.
By the way, you no longer need
@synthesize
directives and you should get into the habit of referring to properties viaself
rather than accessing the underlying iVar (which would be_rssiArray
if you remove the@synthesize
)