我試圖通過藍牙在iOS和OSX之間發送/接收數據。是否可以通過CoreBluetooth將iPhone4S連接到MBA?
由於GameKit不支持OSX,我需要使用其他選項。 iPhone4S和最新的Mac Book Air支持藍牙4.0, ,所以我認爲可以在這些設備之間建立連接。
但我下面的示例代碼不起作用,需要你的幫助。 雖然我只是創建CBCentralManager並開始掃描設備(有兩個的iPhone4S和MBA在手), - centralManager:didDiscoverPeripheral:advertisementData:RSSI:從未被稱爲...
- (void)start {
self.mgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil] autorelease];
NSDictionary * opts = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[self.mgr scanForPeripheralsWithServices:nil options:opts];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// not called this delegate method...
}
這有什麼錯我的代碼?我錯過了什麼嗎?