-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI{
ScanInfo *scanInfo = [[ScanInfo alloc] initWithPeripheral:peripheral number:RSSI];
if ([_scanArr containsObject:peripheral]) {
NSInteger index = [_scanArr indexOfObject:peripheral];
[_scanArr removeObjectAtIndex:index];
[_scanInfoArr removeObjectAtIndex:index];
}
[_scanInfoArr addObject:scanInfo];
[_scanArr addObject:peripheral];
self.scanBlock(peripheral);
}
@interface ScanInfo : NSObject
@property(nonatomic,strong)CBPeripheral *peripheral;
@property(nonatomic,strong)NSNumber *number;
- (instancetype)initWithPeripheral: (CBPeripheral *)peripheral number: (NSNumber *)number;
@end
@implementation ScanInfo
- (instancetype)initWithPeripheral: (CBPeripheral *)peripheral number: (NSNumber *)number
{
self = [super init];
if (self) {
_peripheral = peripheral;
_number = number;
}
return self;
}
@end