Skip to content

Instantly share code, notes, and snippets.

@adkron
Last active March 23, 2016 03:37
Show Gist options
  • Save adkron/a9f34ae4af8d33ddb7d0 to your computer and use it in GitHub Desktop.
Save adkron/a9f34ae4af8d33ddb7d0 to your computer and use it in GitHub Desktop.
Estimate Nearable
//
// ViewController.swift
// Airport
//
// Created by Amos King on 3/22/16.
// Copyright © 2016 Binary Noggin. All rights reserved.
//
import UIKit
class ViewController: UIViewController, ESTTriggerManagerDelegate {
let triggerManager = ESTTriggerManager()
override func viewDidLoad() {
super.viewDidLoad()
print("Hello World")
// 3. Set the trigger manager's delegate
self.triggerManager.delegate = self
let rule1 = ESTOrientationRule.orientationEquals(
.HorizontalUpsideDown, forNearableType: .Car)
let rule2 = ESTMotionRule.motionStateEquals(
true, forNearableIdentifier: "D0D3FA86-CA76-45EC-9BD9-6AF451A3E587")
let trigger = ESTTrigger(rules: [rule1, rule2], identifier: "tom the trigger")
self.triggerManager.startMonitoringForTrigger(trigger)
print("Hello World")
}
func triggerManager(manager: ESTTriggerManager!,
triggerChangedState trigger: ESTTrigger!) {
if (trigger.identifier == "tom the trigger" && trigger.state == true) {
print("Hello, digital world! The physical world has spoken.")
} else {
print("Goodnight. <spoken in the voice of a turret from Portal>")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment