作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在处理外设扫描仪,但我遇到了 if 循环问题。我收到错误:“for 语句中的预期条件”和“语句的支撑 block 是未使用的闭包”。这是这个循环:
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> {
}
也许您打算遍历 [CBService]
(CBService
的数组):
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!)
{
if let servicePeripherals = peripheral.services as? [CBService]
{
for servicePeripheral in servicePeripherals
{
println("\(servicePeripheral)")
}
}
}
关于ios - 如果外围设备出现问题则循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25603209/
我有一个基于 Java 的应用程序 (Android),我希望能够在后台执行可能长时间的操作。 AsyncTask 上的 Android 文档建议不要将它们用于可能运行时间超过几秒的任务(这是为什么?
所以我有外围 BLE 设备,我需要一些标识符以便稍后与另一部 iPhone 共享。示例我将 iPhone 'A' 连接到外围设备。 iPhone 'A' 将外围设备的标识符保存到数据库中,稍后我可以轻
当我指定这样的服务时: centralManager.scanForPeripherals(withServices:[BEAN_SERVICE_UUID],选项:[CBCentralManagerS
我是一名优秀的程序员,十分优秀!