描述:
大神们,我问一个很简单的问题,这个我怎么过滤我要只定得数据,比如我要service.uuid.UUIDString=‘0‘的数据,这个要怎么写得
源码
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(MainStoryboard.peripheralServiceCell, forIndexPath: indexPath) as! NameUUIDCell
let service = peripheral.services.filter({ (Service) -> Bool in
<#code#>
})[indexPath.row]
print(service.uuid)
print(service.uuid.UUIDString)
cell.nameLabel.text = service.name
cell.uuidLabel.text = service.uuid.UUIDString
if self.peripehealConnected {
cell.nameLabel.textColor = UIColor.blackColor()
} else {
cell.nameLabel.textColor = UIColor.lightGrayColor()
}
ret
解决方案1:
不要这么去处理,而是控制数据源数据,然后刷新tableview即可
allService是全部的数据源
service是列表的数据源
使用service去展示列表,需要过滤的时候过滤这个数据源即可