我正在做外围扫描仪,我对if循环有问题。我得到错误:“预期条件在for语句”和“带括号的语句块是一个未使用的闭包”。这就是这个循环:
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!)
{
if let servicePeripheral = peripheral.services as? [CBService]
{
for peripheral.services in CBService
{
println("\(servicePeripheral)")
}
}
}发布于 2014-09-01 11:24:21
您的for循环格式很差。你有:
for <some existing value> in <a data type> {
}相反,你想:
for <new variable> in <some collection> {
}也许您打算遍历[CBService] (CBService数组):
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!)
{
if let servicePeripherals = peripheral.services as? [CBService]
{
for servicePeripheral in servicePeripherals
{
println("\(servicePeripheral)")
}
}
}https://stackoverflow.com/questions/25603209
复制相似问题