Hi All, I have two application in cocoa . My aim is to communicate with a protocol between both the application using IPC mechanism (through NSConnection) but I am unable to achieve my goal.
I want to use id < MyProtocol > protocol as inout parameter for two way communication. Please see my code below and guide me what I am missing. //***********************************Vendor Process********************************** // Root.h @protocol MyProtocol - (long) getNumber ; @end @protocol RootProtocol - (HRESULT) getData : (id < MyProtocol >) pMyProtocol; @end @interface CRoot : NSObject < RootProtocol> {} @end @protocol RemoteObjProtocol - (id) GetDistObject; @end @interface CRootService : NSObject < RemoteObjProtocol > {} @end @interface OutClass : NSObject < MyProtocol > {} @end // Root.m @implementation OutClass - (id) init {return self;} - (void) dealloc {[super dealloc];} - (long) getNumber {return 10;} @end @implementation CRoot - (id) init{return self;} - (void) dealloc{[super dealloc];} - (HRESULT) getData : (id < MyProtocol >) pMyProtocol { pMyProtocol = [[[CRootService alloc] init] autorelease]; return S_OK; } @end @implementation CRootService - (id) init { [[NSConnection defaultConnection] setRootObject: self]; [[NSConnection defaultConnection] registerName: @"RootService"]; return self; } - (void) dealloc{[super dealloc];} - (id) GetDistObject { return [[[CRoot alloc] init] autorelease]; } @end //************************Reciever Process************************** /// Test.h @interface CTest : NSObject {} + (id) ReturnDistObj : (NSString*)registeredName; @end // Test.m id remoteProxy; @implementation CTest - (id) init{return self;} - (void) dealloc{[super dealloc];} + (id) ReturnDistObj : (NSString*)registeredName { remoteProxy = [[NSConnection rootProxyForConnectionWithRegisteredName: registeredName host: nil] retain]; [remoteProxy setProtocolForProxy:@protocol(RemoteObjProtocol)]; if (remoteProxy && [remoteProxy conformsToProtocol: @protocol( RemoteObjProtocol)]) { return [remoteProxy GetDistObject] ; } else return NULL; } @end int main() { id < RootProtocol > pRootProtocol = [CTest ReturnDistObj: @"Rootservice"]; id < MyProtocol > pMyProtocol = nil; [pRootProtocol getData: pMyProtocol ]; return 1; } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com