Objective c 在estimote ibeacon上读取温度
在obj-c中,我可以通过以下模块从信标获取温度:Objective c 在estimote ibeacon上读取温度,objective-c,swift,estimote,Objective C,Swift,Estimote,在obj-c中,我可以通过以下模块从信标获取温度: - (void)readTemperatureWithCompletion:(ESTNumberCompletionBlock)completion 我怎样才能在斯威夫特的帮助下完成这件事呢。我一直在研究闭包,但仍然不确定如何在SWIFT中运行此块 有人能提供建议吗 谢谢这对我很有用: func beaconConnectionDidSucceeded(beacon: ESTBeacon) { NSLog("beaconConnect
- (void)readTemperatureWithCompletion:(ESTNumberCompletionBlock)completion
我怎样才能在斯威夫特的帮助下完成这件事呢。我一直在研究闭包,但仍然不确定如何在SWIFT中运行此块
有人能提供建议吗
谢谢这对我很有用:
func beaconConnectionDidSucceeded(beacon: ESTBeacon) {
NSLog("beaconConnectionDidSucceeded")
beacon.readTemperatureWithCompletion() { value, error in
NSLog("readTemperatureWithCompletion, value = \(value), error = \(error)")
}
}
这对我很有用:
func beaconConnectionDidSucceeded(beacon: ESTBeacon) {
NSLog("beaconConnectionDidSucceeded")
beacon.readTemperatureWithCompletion() { value, error in
NSLog("readTemperatureWithCompletion, value = \(value), error = \(error)")
}
}
我相信这是比较正确的
beacon.readTemperatureWithCompletion({(temp:NSNumber!, error:NSError?) -> () in
if error? == nil{
println("\(temp)")
}else
{
println("Error \(error!.description)")
}
})
我相信这是比较正确的
beacon.readTemperatureWithCompletion({(temp:NSNumber!, error:NSError?) -> () in
if error? == nil{
println("\(temp)")
}else
{
println("Error \(error!.description)")
}
})
说得好,谢谢!我更新了上面的代码,同时使用了尾随语法和类型推断。很好,谢谢!我更新了上面的代码,以使用尾随语法和类型推断。