You almost never want to do this, the only typical exception is that you want to pass the link as an argument that can be populated. See usage (NSError **) in all APIs.
In particular, you do not want to declare an instance variable as NSConnection ** , and then set it somewhere else; somewhere outside the facility. This completely breaks the encapsulation and is a sure sign that your code is poor or at least weirdly designed.
Try this instead:
@interface MyClass:NSObject { NSConnection *connection; } @property(retain) NSConnection *connection; @end @implementation MyClass @synthesize connection; @end
And in any class / code you need to establish a connection:
@implementation SomeOtherClass - (void) configureConnection: (MyClass *) anObject { NSConnection *aConnection; aConnection = ... initialize the connection ... anObject.connection = aConnection; } @end
This will preserve encapsulation and allow something else to configure the connection for MyClass. If this does not solve your problem, you need to tell us exactly what you are trying to do.
bbum
source share