【发布时间】:2014-09-15 14:10:35
【问题描述】:
我的应用扫描蓝牙设备并显示在表格中。但是,有时它会扫描同一设备两次或多次,并在表格中多次显示同一设备。
我需要过滤它。当设备的名称或 UUID 重复时,表格将只显示一次。
编辑: 这是我尝试过的,但不起作用...
CBPeripheral peripheral = this._peripherals [indexPath.Row];
List<string> filter = new List<string>();
filter.Add (peripheral.Identifier.AsString());
string[] array = {};
foreach (var c in filter) {
if (!ReferenceEquals (c, array)) {
int x = array.Length;
filter.CopyTo (0, array, 0, x);
}
}
foreach (string i in array) {
Console.WriteLine ("ARRAY: "+i.ToString());
}
【问题讨论】:
-
在链接上查看这个问题的公认答案! stackoverflow.com/questions/1439564/…
-
表格视图中的数据是什么样的?您是在使用模型对象,还是仅使用数组中的设备名称?当你扫描一个设备两次时,你有两个具有相同值的模型对象,还是数组中的同一个对象两次?如果是后者,请使用 NSSet 或 NSOrderedSet 而不是数组。
-
Nofel,我是一名 Xamarin 开发人员。你发给我一个带有 Xcode 代码的主题。我是初学者
标签: c# ios uitableview xamarin bluetooth-lowenergy