Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如果外围设备出现问题,则循环_Ios_Swift_Bluetooth Lowenergy - Fatal编程技术网

Ios 如果外围设备出现问题,则循环

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

我正在处理外围扫描仪,我有中频环路的问题。 我得到错误:“for语句中的预期条件”和“带括号的语句块是未使用的闭包”。这就是这个循环:

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)")
        }
    }
}