Ios 如果外围设备出现问题,则循环
我正在处理外围扫描仪,我有中频环路的问题。 我得到错误:“for语句中的预期条件”和“带括号的语句块是未使用的闭包”。这就是这个循环:Ios 如果外围设备出现问题,则循环,ios,swift,bluetooth-lowenergy,Ios,Swift,Bluetooth Lowenergy,我正在处理外围扫描仪,我有中频环路的问题。 我得到错误:“for语句中的预期条件”和“带括号的语句块是未使用的闭包”。这就是这个循环: func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!) { if let servicePeripheral = peripheral.services as? [CBService] { for peripheral.servi
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!)
{
if let servicePeripheral = peripheral.services as? [CBService]
{
for peripheral.services in CBService
{
println("\(servicePeripheral)")
}
}
}
您的
for
循环格式不正确。你有:
for <some existing value> in <a data type> {
}
for <new variable> in <some collection> {
}
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!)
{
if let servicePeripherals = peripheral.services as? [CBService]
{
for servicePeripheral in servicePeripherals
{
println("\(servicePeripheral)")
}
}
}