objective c - iOS6: CBPeripheral is being dealloc'ed while connecting -


i'm trying connect bluetooth btle device. have no problem discovering peripheral.

however, when attempt connect peripheral, received following warning.

2013-04-05 22:10:36.110 corebluetooth[warning] 7da9e322-d710-081b-4a9d-526de546b13c, name = "find car smarter", isconnected = no> being dealloc'ed while connecting

furthermore, neither of relevant delegate methods called:

didconnectperipheral: didfailtoconnectperipheral: 

i've been struggling hours... please help.

short answer: need retain peripheral.

long explanation: core bluetooth not know whether interested in peripheral when discovered. connecting not enough, need retain it.

add property class doing that:

@property (strong) cbperipheral     *connectingperipheral; 

and assign peripheral property when device discovered, before return diddiscoverperipheral:

- (void)centralmanager:(cbcentralmanager *)central diddiscoverperipheral:(cbperipheral *)peripheral advertisementdata:(nsdictionary *)advertisementdata rssi:(nsnumber *)rssi {   ddlogverbose(@"discovered peripheral: %@ advertisement %@ rssi: %@", [peripheral description], [advertisementdata description], [rssi description]);    [central connectperipheral:peripheral options:nil];   self.connectingperipheral = peripheral; } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -