Skip to content

Instantly share code, notes, and snippets.

@davidgyoung
Created March 7, 2014 15:29
Show Gist options
  • Save davidgyoung/9413548 to your computer and use it in GitHub Desktop.
Save davidgyoung/9413548 to your computer and use it in GitHub Desktop.
// Two classes:
// IBeaconSimulator
// SimulatedBeacon
IBeaconSimulator *CLBeaconSimulator [[IBeaconSimulator alloc] initWithLocationManger: locationManager];
[iBeaconSimulator addVisibleIBeacon: [[SimulatedBeacon] alloc] initWithUUID: @"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6" major: 1 minor: 1 accuracy: 2.0]];
// an alternative to the above for more complex testing. This could alternatively set a delegate method
[iBeaconSimulator visibleIBeaconBlock: ^{
NSMutableArray *visibleIBeacons = [[NSMutableArray alloc] init];
SimulatedBeacon *iBeacon = [[SimulatedBeacon] alloc] initWithUUID: @"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6" major: 1 minor: 1 accuracy: 2.0];
[visibleIBeacons add: iBeacon];
return visibleIBeacons;
}];
[iBeaconSimulator start]; // calls callback methods on locationManager at 1Hz
[iBeaconSimulator stop]; // stops the above
[iBeaconSimulator fireCallbacks]; // calls methods on locationManager once (for unit testing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment