Hi,
first I want to thank you that you made it really easy via Cocoapods to program a iOS app.
But on the other hand I have currently a problem with it. Maybe it is, because I am a not very experienced programmer.
When I try to get a value of a variable from my core I get following error:
'fatal error: unexpectedly found nil while unwrapping an Optional value’
Here is my swift code:
// list all connected cores
var myCore : 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 == "wifiduino" {
myCore = device
}
}
}
}
}
// read variable countDown from Core
myCore!.getVariable("countDown", completion: { (result:AnyObject!, error:NSError!) -> Void in
if let e=error {
println("Failed reading countdown from device")
}
else {
if let countDown = result as? Int {
println("The countdown is \(countDown)")
}
}
})
}
I have done all teh steps of the bridging from Cocoa to Swift and I also get a positive logged in result, when I do not try to read the variable.
I also double checked the variable name, which is correct.
Does anybody have some idea what I have done wrong?
Best regards,
Chrisitan