On May 4, 2005, at 8:25 PM, James Bucanek wrote:
My main problem is the lifetime of the NSConnection object itself. Everything else pretty much takes care of itself, but I can't determine a definative time when the NSConnection object can be released.
If I let my application leak NSConnection objects, it works fine. ;)
If no one can come up with an answer to this, I might end up creating an NSConnection pool/factory and do some "lazy" garbage collection.
This sounds like a candidate for one of the -performSelector... methods in NSObject, with a delay of 0. Delayed performs are good for cases when you:
(a) can't send the message you want to send (like -release) right this moment, because
(b) you're in the middle of something (like using the object you would be releasing), but
(c) you want to send the message just as soon as you're done with that something.
Your idea of a NSConnection pool would essentially be a hand-rolled version of delayed performs.