Skip to content

Instantly share code, notes, and snippets.

@anditto
Last active August 29, 2015 14:05
Show Gist options
  • Save anditto/07e0496cbdb51d199baf to your computer and use it in GitHub Desktop.
Save anditto/07e0496cbdb51d199baf to your computer and use it in GitHub Desktop.
- (void)pushBeaconInfo
{
for (int i = 0; i < self.beaconsArray.count; i++) {
NSString *beaconMajorString = [((ESTBeacon *) self.beaconsArray[i]).major stringValue];
NSString *beaconMinorString = [((ESTBeacon *) self.beaconsArray[i]).minor stringValue];
NSNumber *beacondist = ((ESTBeacon *) self.beaconsArray[i]).distance;
// Beacon Major
((UILabel *) self.majorArray[i]).text = beaconMajorString;
// Beacon Minor
((UILabel *) self.minorArray[i]).text = beaconMinorString;
// Beacon Distance
if ( (beacondist) && (![[beacondist stringValue] isEqualToString:@"-1"]) )
{
((UILabel *) self.distArray[i]).text = [NSString stringWithFormat:@"%.02f", [beacondist floatValue]];
if ([beacondist floatValue] < 2.0)
{
((UILabel *) self.distArray[i]).backgroundColor = [UIColor colorWithRed:(2.0 - [beacondist floatValue])/2.0 green:0.0 blue:[beacondist floatValue]/2.0 alpha:1.0];
}
}
if ( (beacondist) && ([beacondist floatValue] < 0.5) && (![[beacondist stringValue] isEqualToString:@"-1"]) )
{
self.messageLabel.text = @"You found it!";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment