After some research I haven’t figure it out yet. How am I able to view my linked devices to my Particle account in a simple tableview in Swift? I am trying with the code from the Reference in DOCS.
var myPhoton : SparkDevice?
SparkCloud.sharedInstance().getDevices { (sparkDevices:[AnyObject]?, error:NSError?) -> Void in
if let e = error {
println("Check your internet connectivity")
}
else {
if let devices = sparkDevices as? [SparkDevice] {
for device in devices {
if device.name == "myNewPhotonName" {
myPhoton = device
}
}
}
}
}
This is my current code:
import UIKit
class Second_ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
func myDeviceList() {
var myPhoton : SparkDevice?
SparkCloud.sharedInstance().getDevices { (sparkDevices:[AnyObject]?, error:NSError?) -> Void in
if let _ = error {
print("Check your internet connectivity")
}
else {
if let devices = sparkDevices as? [SparkDevice] {
for device in devices {
if device.name == "myNewPhotonName" {
myPhoton = device
}
}
}
}
}
}
internal func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I am using Xcode 7.3.1 and Swift 3. I’ve installed Cocoapods, done pod install and created Bridging Header. I’ve managed to show the login wizard and login successfully.