Reputation: 41
Im' quite new at swift and for my project I need to use swift3 and xcode8.1 I tried differents solutions, but noting works. I think it's because of the swift3 from swift2 conversion as I can see on differents topics. Nevertheless that didn't help me a lot.
Here is my function:
func startHeartRateUpdates() {
output("Starting Heart Rate updates...")
if let client = self.client {
do {
try client.sensorManager.startHeartRateUpdates(to: nil, withHandler: { (heartRateData: MSBSensorHeartRateData!, error: NSError!) in
self.hrLabel.text = NSString(format: "Heart Rate: %3u %@",
heartRateData.heartRate,
heartRateData.quality == MSBSensorHeartRateQuality.acquiring ? "Acquiring" : "Locked") as String
})
self.perform(#selector(ViewController.stopHeartRateUpdates), with: nil, afterDelay: 60)
} catch let error as NSError {
output("startHeartRateUpdatesToQueue failed: \(error.description)")
}
} else {
output("Client not connected, can not start heart rate updates")
}
}
And the only error I had is this 2 lines undernlined in red:
heartRateData.quality == MSBSensorHeartRateQuality.acquiring ? "Acquiring" : "Locked") as String
With the message:
'Int1' is not convertible to 'Bool'
Thanks for your help.
Upvotes: 1
Views: 2859
Reputation: 232
I think the field acquiring
is an int
type. If you use int
type in condional statement as a condion you should use ==
.
Example:
heartRateData.quality = MSBSensorHeartRateQuality.acquiring == 1 ? "Acquiring" : "Locked") as String
Upvotes: 1