• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to unregister a device delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to unregister a device delegate


  • Subject: Re: How to unregister a device delegate
  • From: Craig Dooley <email@hidden>
  • Date: Wed, 16 Sep 2009 10:56:54 -0700

[_rfcommChannel setDelegate:nil];

On Sep 16, 2009, at 8:12 AM, Peter Sichel wrote:

I'm using Apple's RFComm sample code and have noticed that in Snow Leopard closing a Bluetooth device has become asynchronous.

More specifically, if you open a channel to a device using:

ioResult = [device openRFCOMMChannelAsync:&_rfcommChannel withChannelID:rfcommChannelID delegate:self];

The caller becomes the delegate per the last parameter.
When you later close the device using:

 [_rfcommChannel closeChannel]

and

 [_bluetoothDevice closeConnection]

If you then release the caller, your program will crash when the device object tries to call the previously registered delegate some arbitrary time later.

There has to be some way to unregister a device delegate so you can be sure the device object will not attempt to call you after your delegate object has gone away.

The existing sample code and framework headers fail to document this so I'm trying to figure out how to unregister my delegate. An ugly work around is to never release a delegate until your program quits.

Is there a better way?

- Peter

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >How to unregister a device delegate (From: Peter Sichel <email@hidden>)

  • Prev by Date: How to unregister a device delegate
  • Next by Date: IOBluetoothRFCOMMChannel and memory management
  • Previous by thread: How to unregister a device delegate
  • Next by thread: IOBluetoothRFCOMMChannel and memory management
  • Index(es):
    • Date
    • Thread