Created
February 9, 2016 09:21
-
-
Save xslim/d0fc04817b32451e37ac to your computer and use it in GitHub Desktop.
MFi Devices list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import ExternalAccessory | |
class DevicesViewController: UITableViewController { | |
var manager = EAAccessoryManager.sharedAccessoryManager() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
manager.registerForLocalNotifications() | |
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("deviceConnected:"), name: EAAccessoryDidConnectNotification, object: nil) | |
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("deviceDisconnected:"), name: EAAccessoryDidDisconnectNotification, object: nil) | |
} | |
func deviceConnected(notification: NSNotification) { | |
tableView.reloadData() | |
if let acc = notification.userInfo![EAAccessoryKey] { | |
showAccessoryInfo(acc as! EAAccessory) | |
} | |
} | |
func deviceDisconnected(notification: NSNotification) { | |
tableView.reloadData() | |
} | |
func showAccessoryInfo(accessory: EAAccessory) { | |
UIAlertView(title: "\(accessory.manufacturer) \(accessory.name)", message: "\(accessory.description)", delegate: nil, cancelButtonTitle: "OK").show() | |
} | |
override func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
return 1 | |
} | |
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return manager.connectedAccessories.count | |
} | |
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) | |
let acc = manager.connectedAccessories[indexPath.row] | |
cell.textLabel?.text = "\(acc.manufacturer) \(acc.name)" | |
cell.detailTextLabel?.text = "\(acc.modelNumber) \(acc.serialNumber)\n fr:\(acc.firmwareRevision) hr: \(acc.hardwareRevision)" | |
return cell | |
} | |
override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) { | |
let acc = manager.connectedAccessories[indexPath.row] | |
showAccessoryInfo(acc) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<array> | |
<string>com.verifone.pmr.zontalk</string> | |
<string>com.verifone.pmr.xpi</string> | |
</array> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment