一:外圍設(shè)備
1.藍(lán)牙中用到的方法:如下:一定要掌握
CBPerpheral(外圍設(shè)備): 屬性有:state ?name ,services; ?方法有:readRSSI discoverServices ?discoverCharacteristic ? writeValueforCharacteristic(寫入數(shù)據(jù)) ?setNotifyValueforCharacteristic(讀取數(shù)據(jù)) ?readValueForDescriptor ? ?writeValueForDescriptor ?
2.CBPerpheralDelegate代理方法有:didDiscoverServices ? didUpdateValueForCharateristic ?等等,都是did.. 也即是一些回調(diào)方法
二:中央設(shè)備
1.CBCentralManager(中央設(shè)備,也就是手機(jī)) ?-scanForPeriphralsWithServices ? ? ? ? ? ? ? ? ? ?-connnectPeriphral?
2.代理方法: didUpdateState ? didConnnectPeripheral
三:block回調(diào):
1.在要向外傳值頁面設(shè)置:
.h
@property (nonatomic, copy) void(^passValueBlock)(NSString *str);
這里,void(^)(NSString *)為類型? , passValueBlock為變量
.m
if (_passValueBlock != nil) {
//_passValueBlock為block型的變量
_passValueBlock(self.backTextFeild.text);
}
2.需要接受的頁面:
BViewController *BVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"bVC"]; // storyBorad創(chuàng)建的頁面不能直接用alloc init.
[BVC setPassValueBlock:^(NSString *str) {
[self.nextBtn setTitle:str forState:UIControlStateNormal];
}];