Re: Core Data Save As Binary Error
Have you changed the storetype to binary in info.plist file Regards SKiran On 14-Dec-09, at 6:11 PM, Richard Somers wrote: I have a Core Data document based application. Saving the file as XML or SQLite works fine. Saving as binary results in an error: *** -[NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs. The struct in question is a transformable attribute using a custom value transformer. - (id)transformedValue:(id)value { return [NSArchiver archivedDataWithRootObject:value]; } No where in my code do I call NSKeyedArchiver. Why does the core data framework work fine saving as XML or SQLite but not binary? --Richard ___ 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/kirankumar.s%40prithvisolutions.com This email sent to kirankuma...@prithvisolutions.com ___ 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
Re: Custom background in NSTableHeaderView
Hi, CellAttributes are used by button and button cell for displaying image and text accordingly, but tableHeaderCell doesn't uses these attributes for displaying image and text.. Customize the NSTableHeaderCell and draw the image and text in drawWithFrame method. Thanks SKiranKumar On 16-Nov-09, at 4:12 PM, Symadept wrote: Hi, I am trying to display custom image and the attributed text into the TableHeaderview. For this I am retrieving the HeaderCell of each TableColumn and setting its image and attributed text. Then I found out If I set image first and then text next, only attributed text shown with the default headerview background. If the Image is set after Text then Background image overlaps the text. I am overriding NSTableView and doing two things. 1. setDrawsBackground:NO 2. Invoking empty drawBackgroundInClipRect:clipRect. Here is my code. - (void)setColumnHeaderOf:(id)identifier image:(NSImage*)image title:( NSString*)title { NSTableColumn *column=[self tableColumnWithIdentifier:identifier]; [[column headerCell] setCellAttribute:NSCellHasImageOnLeftOrBottom to: NSImageBelow]; [[column headerCell] setImage:image]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:title]; NSMutableParagraphStyle * aParagraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; [aParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail]; [aParagraphStyle setAlignment:NSCenterTextAlignment]; CGFloat dividingFactor = 255.0f; NSMutableDictionary * aTitleAttributes = [[[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSFont fontWithName:CP_FONT_NAME size:[NSFont systemFontSize]], NSFontAttributeName, aParagraphStyle, NSParagraphStyleAttributeName, nil] autorelease]; [aTitleAttributes setValue:[NSColor colorWithDeviceRed:(246/ dividingFactor) green:(204/dividingFactor) blue:(37/dividingFactor) alpha:1.0f] forKey: NSForegroundColorAttributeName]; [attributedString addAttributes:aTitleAttributes range:NSMakeRange(0, [attributedString length])]; [[column headerCell] setAttributedStringValue:attributedString]; [attributedString release]; } - (void)awakeFromNib { NSLog(@KBCustomTableView awakeFromNib); [[self enclosingScrollView] setDrawsBackground:NO]; NSRect frameRect = [[self headerView] frame]; [[self headerView] setFrameSize:NSMakeSize(frameRect.size.width, 30)]; [self setColumnHeaderOf:@Column1 image:[NSImage imageNamed:@ColHdr1] title:@Column1]; [self setColumnHeaderOf:@Column2 image:[NSImage imageNamed:@ColHdr2] title:@Column2]; [self setColumnHeaderOf:@Column3 image:[NSImage imageNamed:@ColHdr3] title:@Column3]; } - (void)drawBackgroundInClipRect:(NSRect)clipRect { NSLog(@KBCustomTableView drawBackgroundInClipRect); //[super drawBackgroundInClipRect:clipRect]; } Thanks in advance. Regards symadept ___ 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/kirankumar.s%40prithvisolutions.com This email sent to kirankuma...@prithvisolutions.com ___ 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
Re: Multiple relationships between two entities
Create a Link Entity by adding another property linkType which decides the normal or alternate link. In Item entity make to-many- relationShip for relationship link Thanks Kiran On 13-Oct-09, at 11:34 AM, Rob Keniger wrote: I'm just getting started with Core Data so go easy on me. I am moving my existing app across to Core Data and I'm having trouble with a few concepts. At present (pre-Core Data) my app has a model object (Item) which is used as the node object in an NSTreeController. This model object has multiple ivars of another custom object (Link) like so: @interface Item : NSObject { Link* normalLink; Link* alternateLink; } @end I'm trying to replicate this in my Core Data model. I have set up two entities, Item and Link. I have created two relationships in the Item entity, normalLink and alternateLink, both pointing to the Link entity. Basically, I want each of these relationships to point to an instance of the Link entity. However, now I have a problem. My Link entity has one relationship (item) which should be the inverse relationship, but that's not possible because I can only have one inverse relationship. I think I'm getting mixed up here, how should this actually be modelled? -- Rob Keniger ___ 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/kirankumar.s%40prithvisolutions.com This email sent to kirankuma...@prithvisolutions.com ___ 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
Wrong selection Index
I had a table with 3 columns(col1, col2, col3(buttonCell)) in which col1 and col2 columns are binded to an Array Controller .Col3 is button cell which is targeted to an action method. When changed selection by clicking the button , in the button cell target method if i ask for selection index on array controller i am getting previous selection index, and if changed my selection by clicking on a row which contains col1 or col2 i am getting correct selection index. Can any one suggest how to get the correct selection index in cell target method even my selection changes by clicking directly on button of a particular row. Regards SKiran ___ 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
problem with NSTimer
according to documentation for beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: it says that While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window- close events) unless they are associated with the sheet. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. But in my app the timer i had created fires even my main window is in running as Modal - (id)init { self = [super init]; if (self) { timer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(timerPinged:) userInfo:nil repeats:YES]; } return self; } -(void)timerPinged:(NSTimer*)timere { NSLog(@timer pinged); } -(IBAction)raiseSheet:(id)sender { [NSApp beginSheet:syncPanel modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; } ___ 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
NSDistantObject exception when server trying to access registered clients using DO
I am developing a client/server application using distributed objects. I developed server and in that i vended an object to be accessible by clients.In the client side i am getting the vended object, and getting required info from server.Every thing works fine. Until now my client ask server for his queries and server replies to that. But on the serverside if any updates goes, i had to inform client.so i thought of registering the client and ping the client for the updates.In the Client side i am getting vended object and registering the client.When my server pings the client giving the following exception. 2009-05-05 12:12:29.023 Project X[5278:10b] *** NSDistantObject initWithCoder: 0x1 not given away for conn 0xf9f21e0 Any one please help me out in this its really annoying Server - NSRunLoop *runloop = [NSRunLoop currentRunLoop]; if ([NSHost respondsToSelector:@selector(_fixNSHostLeak)]) [NSHost _fixNSHostLeak]; if ([NSSocketPort respondsToSelector: @selector(_fixNSSocketPortLeak)]) [NSSocketPort _fixNSSocketPortLeak]; NSSocketPort *receivePort = [[NSSocketPort alloc] initWithTCPPort:PORT_NUMBER]; NSConnection *connection = [[NSConnection alloc] initWithReceivePort:receivePort sendPort:nil]; [receivePort release]; [connection enableMultipleThreads]; [connection setRootObject:[ServerObject sharedServerObject]]; [connection addRunLoop:runloop]; [connection setDelegate:self]; [receivePort release]; [runloop run]; -- -- if the socket is created as above , there is no exception when i am trying to ping registered clients.But the problem with above is ,some times socket is not allocated, so i thought of creating socket in the following way -- -- int newSocket = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in serverAddress; memset(serverAddress, 0, sizeof(serverAddress)); serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_port = htons(PORT_NUMBER); //resusing the Socket int yes = 1; setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, yes, sizeof(yes)); bind(newSocket, (struct sockaddr *)serverAddress, sizeof(serverAddress); listen(newSocket, 128); NSSocketPort *serverPort = [[NSSocketPort alloc] initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:0 socket:newSocket]; serverConnection = [NSConnection connectionWithReceivePort:serverPort sendPort:serverPort]; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; [serverConnection enableMultipleThreads]; [serverConnection setRootObject:[ServerObject sharedServerObject]]; [serverConnection addRunLoop:runloop]; [serverConnection setDelegate:self]; [runloop run]; [serverConnection release]; -- Beacuse of above creation of scoket i am getting above exception @protocol DServerProto -(void)registerClient:(id)client withName:(NSString *)name; -(void)exportProject:(NSDictionary *)projectDictionary; @end @implementation ServerObject -(void)registerClient:(id)client withName:(NSString *)name { [clients setObject:client forKey:name]; [client setProtocolForProxy:@protocol(DClientProto)]; if(![timer isValid]) { timer = [[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(pingClients:) userInfo:nil repeats:YES] retain]; } } -(void)pingClients:(NSTimer *)pingTimer { NSArray *clientKeys = [clients allKeys]; for(id key in clientKeys) { @try { [[clients objectForKey:key] ping]; } @catch (NSException *exception) { [clients removeObjectForKey:key]; } } if(![[clients allKeys] count] [timer isValid]) { [timer invalidate];
Exception
i am developing a client/server app using Distributed objects, i register my client to server. when server pings the client the following exception occurs. Can any one suggest me why this exception occurs, 2009-05-05 12:12:29.023 Project X[5278:10b] *** NSDistantObject initWithCoder: 0x1 not given away for conn 0xf9f21e0 2009-05-05 12:12:29.024 Project X[5278:10b] NSExceptionHandler has recorded the following exception: NSInternalInconsistencyException -- *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 0xb6119a 0x94372e3b 0x95d8aeeb 0x95d8af2a 0x90e847bc 0x90e8425d 0x90e8074c 0x90e8386e 0x90e8358d 0x90e830be 0x90fc4395 0x90fc37ae 0x95d1a87c 0x95d1bf65 0x95d115f5 0x95d11cd8 0x910e9480 0x910e9299 0x910e910d 0x96bff3ed 0x96bfeca0 0x96bf7cdb 0x38f926 0x96bc4f14 0x37735 0x2cb6 0x1 An Project X exception of type NSInternalInconsistencyException occured. *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 1 +[NSException raise:format:arguments:] (in CoreFoundation) + 155 2 +[NSException raise:format:] (in CoreFoundation) + 58 3 -[NSConcretePortCoder decodeInvocation] (in Foundation) + 1068 4 -[NSConcretePortCoder decodeRetainedObject] (in Foundation) + 909 5 _NSWalkData2 (in Foundation) + 1724 6 -[NSConnection handleRequest:sequence:] (in Foundation) + 78 7 -[NSConnection handlePortCoder:] (in Foundation) + 1149 8 -[NSConcretePortCoder dispatch] (in Foundation) + 142 9 -[NSSocketPort _handleMessage:from:socket:] (in Foundation) + 821 10 __NSFireSocketData (in Foundation) + 734 11 __CFSocketDoCallback (in CoreFoundation) + 476 12 __CFSocketPerformV0 (in CoreFoundation) + 133 13 CFRunLoopRunSpecific (in CoreFoundation) + 3141 14 CFRunLoopRunInMode (in CoreFoundation) + 88 15 RunCurrentEventLoopInMode (in HIToolbox) + 283 16 ReceiveNextEventCommon (in HIToolbox) + 374 17 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 106 18 _DPSNextEvent (in AppKit) + 657 19 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 128 20 -[NSApplication run] (in AppKit) + 795 21 -[MainApp run] (in Project X) (MainApp.m:506) 22 NSApplicationMain (in AppKit) + 574 23 main (in Project X) (main.m:28) 2009-05-05 12:12:31.725 Project X[5278:10b] *** -[NSConcretePortCoder decodeInvocation]: no local target Regards SKiran ___ 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
Re: Registering Clients using DO
Creating socket as below in the server side gives the exception. Can any one guide why this happens so. int newSocket = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in serverAddress; int namelen = sizeof(serverAddress); memset(serverAddress, 0, sizeof(serverAddress)); serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_port = htons(8081); int yes = 1; setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, yes, sizeof(yes)); bind(newSocket, (struct sockaddr *)serverAddress, namelen); listen(newSocket, 128); NSSocketPort *receivePort = [[NSSocketPort alloc] initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:0 socket:newSocket]; NSConnection *connection = [NSConnection connectionWithReceivePort:receivePort sendPort:receivePort]; if i create the port as below then it doesn't gives the exception NSSocketPort *receivePort; NSConnection *connection; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; // Magic fix for socketPort/host leaks! if ([NSHost respondsToSelector:@selector(_fixNSHostLeak)]) { [NSHost _fixNSHostLeak]; } if ([NSSocketPort respondsToSelector: @selector(_fixNSSocketPortLeak)]) { [NSSocketPort _fixNSSocketPortLeak]; } NS_DURING // This server will wait for requests on port 8081 receivePort = [[NSSocketPort alloc] initWithTCPPort:PORT_NUMBER]; NS_HANDLER exit(-1); NS_ENDHANDLER // Create the connection object connection = [NSConnection connectionWithReceivePort:receivePort sendPort:nil]; [receivePort release]; [connection enableMultipleThreads]; [connection setRootObject:[ServerObject sharedServerObject]]; [connection addRunLoop:runloop]; [connection setDelegate:self]; [receivePort release]; Regards SKiran On 05-May-09, at 11:10 AM, Kiran Kumar S wrote: hi ken, So, the questions are: is -getServer called on the main thread? Is the client object, the one which you pass to the server with - registerClient:. retained so that it is still alive when the ping comes? the object i send is shared object, which exist until the application quits. Regards SKiran On 30-Apr-09, at 2:08 PM, Ken Thomases wrote: On Apr 30, 2009, at 3:06 AM, Kiran Kumar S wrote: On 30-Apr-09, at 12:03 PM, Ken Thomases wrote: On Apr 30, 2009, at 12:47 AM, Kiran Kumar S wrote: I am developing a client/server application using DO. In server an object is vended to be accessible by clients.In the client side i am accessing vended object and get required info from server.Every thing works fine. Until now my client queries server and server replies to that. But on serverside if any updates goes, i had to inform client.so i thought of registering the client and ping the client for updates.So in Client side i get vended object and registered it to server.When my server pings the client its giving error *** NSDistantObject initWithCoder: 0x1 not given away for conn 0xf8937f0 Can you break on this error? On what line of code is it happening? What's the backtrace? this exception occurs when server pings, 2009-04-30 13:22:13.835 Project X[7044:10b] *** NSDistantObject initWithCoder: 0x1 not given away for conn 0x10c17ce0 It looks like the above is separate from the below exception, although probably related. That message is far from clear. An Apple engineer may be able to help. It seems to be saying that it has received an object identifier (0x1) which doesn't correspond to any object that was sent out on the connection in question. 2009-04-30 13:22:13.836 Project X[7044:10b] NSExceptionHandler has recorded the following exception: NSInternalInconsistencyException -- *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 0xb5919a 0x94372e3b 0x95d8aeeb 0x95d8af2a 0x90e847bc 0x90e8425d 0x90e8074c 0x90e8386e 0x90e8358d 0x90e830be 0x90fc4395 0x90fc37ae 0x95d1a87c 0x95d1bf65 0x95d115f5 0x95d11cd8 0x910e9480 0x910e9299 0x910e910d 0x96bff3ed 0x96bfeca0 0x96bf7cdb 0x38de9a 0x96bc4f14 0x37225 0x27a6 0x1 An Project X exception of type NSInternalInconsistencyException occured. *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 1 +[NSException raise:format:arguments:] (in CoreFoundation) + 155 2+[NSException raise:format:] (in CoreFoundation) + 58 3-[NSConcretePortCoder decodeInvocation] (in Foundation) + 1068 4 -[NSConcretePortCoder decodeRetainedObject] (in Foundation) + 909 5_NSWalkData2 (in Foundation) + 1724 6-[NSConnection handleRequest:sequence:] (in Foundation) + 78 7-[NSConnection handlePortCoder:] (in Foundation) + 1149 8
Re: Registering Clients using DO
hi ken, So, the questions are: is -getServer called on the main thread? Is the client object, the one which you pass to the server with - registerClient:. retained so that it is still alive when the ping comes? the object i send is shared object, which exist until the application quits. Regards SKiran On 30-Apr-09, at 2:08 PM, Ken Thomases wrote: On Apr 30, 2009, at 3:06 AM, Kiran Kumar S wrote: On 30-Apr-09, at 12:03 PM, Ken Thomases wrote: On Apr 30, 2009, at 12:47 AM, Kiran Kumar S wrote: I am developing a client/server application using DO. In server an object is vended to be accessible by clients.In the client side i am accessing vended object and get required info from server.Every thing works fine. Until now my client queries server and server replies to that. But on serverside if any updates goes, i had to inform client.so i thought of registering the client and ping the client for updates.So in Client side i get vended object and registered it to server.When my server pings the client its giving error *** NSDistantObject initWithCoder: 0x1 not given away for conn 0xf8937f0 Can you break on this error? On what line of code is it happening? What's the backtrace? this exception occurs when server pings, 2009-04-30 13:22:13.835 Project X[7044:10b] *** NSDistantObject initWithCoder: 0x1 not given away for conn 0x10c17ce0 It looks like the above is separate from the below exception, although probably related. That message is far from clear. An Apple engineer may be able to help. It seems to be saying that it has received an object identifier (0x1) which doesn't correspond to any object that was sent out on the connection in question. 2009-04-30 13:22:13.836 Project X[7044:10b] NSExceptionHandler has recorded the following exception: NSInternalInconsistencyException -- *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 0xb5919a 0x94372e3b 0x95d8aeeb 0x95d8af2a 0x90e847bc 0x90e8425d 0x90e8074c 0x90e8386e 0x90e8358d 0x90e830be 0x90fc4395 0x90fc37ae 0x95d1a87c 0x95d1bf65 0x95d115f5 0x95d11cd8 0x910e9480 0x910e9299 0x910e910d 0x96bff3ed 0x96bfeca0 0x96bf7cdb 0x38de9a 0x96bc4f14 0x37225 0x27a6 0x1 An Project X exception of type NSInternalInconsistencyException occured. *** -[NSConcretePortCoder decodeInvocation]: no local target Stack trace: 1 +[NSException raise:format:arguments:] (in CoreFoundation) + 155 2 +[NSException raise:format:] (in CoreFoundation) + 58 3 -[NSConcretePortCoder decodeInvocation] (in Foundation) + 1068 4 -[NSConcretePortCoder decodeRetainedObject] (in Foundation) + 909 5 _NSWalkData2 (in Foundation) + 1724 6 -[NSConnection handleRequest:sequence:] (in Foundation) + 78 7 -[NSConnection handlePortCoder:] (in Foundation) + 1149 8 -[NSConcretePortCoder dispatch] (in Foundation) + 142 9 -[NSSocketPort _handleMessage:from:socket:] (in Foundation) + 821 10 __NSFireSocketData (in Foundation) + 734 11 __CFSocketDoCallback (in CoreFoundation) + 476 12 __CFSocketPerformV0 (in CoreFoundation) + 133 13 CFRunLoopRunSpecific (in CoreFoundation) + 3141 14 CFRunLoopRunInMode (in CoreFoundation) + 88 15 RunCurrentEventLoopInMode (in HIToolbox) + 283 16 ReceiveNextEventCommon (in HIToolbox) + 374 17 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 106 18 _DPSNextEvent (in AppKit) + 657 19 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 128 20 -[NSApplication run] (in AppKit) + 795 21 -[MainApp run] (in Project X) (MainApp.m:506) 22 NSApplicationMain (in AppKit) + 574 23 main (in Project X) (main.m:28) 2009-04-30 13:22:16.422 Project X[7044:10b] *** - [NSConcretePortCoder decodeInvocation]: no local target @implementation ServerObject : NSObject -(void)registerClient:(idNetClientProto)client { You didn't show the NetClientProto protocol, although I'm guessing it's pretty simple. You didn't comment here. I guess I was too subtle. I was asking to see the protocol declaration. [serverObject performSelector:@selector(registerClient:) withObject:self]; Why are you using -performSelector:... here? What's the declaration of 'serverObject'? Best practice is to have a protocol for each side of the connection, defined in a header that is shared between the code bases. Then you don't have to relying on things like - performSelector:... You could just invoke -registerClient: directly. Such a protocol is also where you'd specify bycopy, oneway, and similar specifiers. Furthermore, you should use -[NSDistantObject setProtocolForProxy:] for efficiency, and probably NSProtocolChecker (on the server side) for security. Thanks , and i will probably implement this It -- the use of a protocol and avoiding the need for - performSelector:.. -- may actually
Registering Clients using DO
I am developing a client/server application using DO. In server an object is vended to be accessible by clients.In the client side i am accessing vended object and get required info from server.Every thing works fine. Until now my client queries server and server replies to that. But on serverside if any updates goes, i had to inform client.so i thought of registering the client and ping the client for updates.So in Client side i get vended object and registered it to server.When my server pings the client its giving error *** NSDistantObject initWithCoder: 0x1 not given away for conn 0xf8937f0 I think my registering of client with server goes wrong , can anyone suggest me what i am missing here.If any sample code that would be great. Server --- main() { int newSocket = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in address; memset(address, 0, sizeof(address)); address.sin_family = AF_INET; address.sin_addr.s_addr = htonl(INADDR_ANY); address.sin_port = htons(PORT_NUMBER);int yes = 1; setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, yes, sizeof(yes)); bind(newSocket, (struct sockaddr *)address, sizeof(address)); listen(newSocket, 128); NSSocketPort *serverPort = [[NSSocketPort alloc] initWithProtocolFamily:PF_INET socketType:SOCK_STREAM protocol:0 socket:newSocket]; connection = [[NSConnection alloc] initWithReceivePort:serverPort sendPort:serverPort]; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; [connection setRootObject:[ServerObject sharedServerObject]]; [connection addRunLoop:runloop]; [runloop run]; } @implementation ServerObject : NSObject -(void)registerClient:(idNetClientProto)client { [clients setObject:client forKey: @C1]; if(![timer isValid]) timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(pingClients) userInfo:nil repeats:YES] retain]; } -(void)pingClients { [[clients objectForKey:[[clients allKeys] lastObject]] ping]; } Client --- -(id)getServer{ @try{ NSSocketPort *port = [[NSSocketPort alloc] initRemoteWithTCPPort:PORT_NUMBER host:host]; NSConnection *connection = [[NSConnection alloc] initWithReceivePort:nil sendPort:port]; [connection setDelegate:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:serverConnection]; [port release]; serverObject = [connection rootProxy]; [serverObject performSelector:@selector(registerClient:) withObject:self]; }...@catch(NSException *exception){ [self destroyConnection]; } return serverObject; } -(void)ping{ NSLog(@server pinged); } Regards SKiran ___ 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
Re: Long Time Dealy When getting Vended Object
When accessing rootProxy from connection Object, in the below code i marked in red -(id)serverObject { id serverObject = nil; @try{ NSConnection *connection = [self serverConnection]; serverObject = [connection rootProxy]; //Here i got struck }...@catch(NSException *exception) { serverObject = nil; [self destroyConnection]; } return serverObject; } -(NSConnection *)serverConnection { if(!serverConnection) { NSString *webAppURLString = [[NSUserDefaults standardUserDefaults] objectForKey:WebAppURL]; NSString *host = nil; if(!(webAppURLString [webAppURLString length] 0)) { host =[[NSProcessInfo processInfo] hostName]; } else { host = [[NSURL URLWithString:webAppURLString] host]; } NSSocketPort *port = [[NSSocketPort alloc] initRemoteWithTCPPort:PORT_NUMBER host:host]; serverConnection = [[NSConnection alloc] initWithReceivePort:nil sendPort:port]; [serverConnection setDelegate:self]; [serverConnection setRequestTimeout:1.0f]; [serverConnection setReplyTimeout:1.0f]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:serverConnection]; [port release]; } return serverConnection; } Regards SKiran On 24-Apr-09, at 6:11 AM, Ken Thomases wrote: On Apr 23, 2009, at 12:05 AM, Kiran Kumar S wrote: These are the lines of code i got blocked 1. When Remote Machine is not in Network 553 -[PXDistributedObjectsClient serverObjectWithReestablishingConnection] 553 -[PXDistributedObjectsClient serverObject] 553 _CF_forwarding_prep_0 553 ___forwarding___ 553 -[NSDistantObject forwardInvocation:] 553 -[NSConnection sendInvocation:internal:] 553 -[NSConnection sendInvocation:internal:] Hmm. I was wrong to suggest sampling. I doesn't resolve to specific lines of code, just functions/methods. Better to break into the program using the debugger (Control-c if using gdb directly, the Pause button in Xcode's debugger) to get the specific line within the -serverObject method. Of course, line numbers won't be meaningful to me without your whole source file, so just show the contents of the line. Regards, Ken ___ 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
Long Time Dealy When getting Vended Object
Hi, Really going mad, it is taking long time response when i am trying to get vended Object from the remote machine which doesn't exist in the network. . I am facing same long time delay(more than 60 sec) when i am trying to get vended object from the remote machine which gone to sleep. Below is the code -(id)serverObject { id serverObject = nil; @try{ serverObject = [[self serverConnection] rootProxy]; }...@catch(NSException *exception) { serverObject = nil; [self destroyConnection]; } return serverObject; } -(NSConnection *)serverConnection { if(!serverConnection) { NSString *webAppURLString = [[NSUserDefaults standardUserDefaults] objectForKey:kPXWebAppURL]; NSString *host = nil; if(!(webAppURLString [webAppURLString length] 0)) { host =[[NSProcessInfo processInfo] hostName]; } else { host = [[NSURL URLWithString:webAppURLString] host]; } NSSocketPort *port = [[NSSocketPort alloc] initRemoteWithTCPPort:PORT_NUMBER host:host]; serverConnection = [[NSConnection alloc] initWithReceivePort:nil sendPort:port]; [serverConnection setDelegate:self]; [serverConnection setRequestTimeout:1.0f]; [serverConnection setReplyTimeout:1.0f]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:serverConnection]; [port release]; } return serverConnection; } Please help me out in this Regards SKiranKumar ___ 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
Re: Long Time Dealy When getting Vended Object
Thanks, Ken for your Reply, Usually we will get time out exception when trying to get vended object that is not available but in the below case i use to get same exception after a long long delay and some times My app crashes Thanks SkiranKumar On 22-Apr-09, at 1:52 PM, Ken Thomases wrote: On Apr 22, 2009, at 1:14 AM, Kiran Kumar S wrote: Really going mad, it is taking long time response when i am trying to get vended Object from the remote machine which doesn't exist in the network. . I am facing same long time delay(more than 60 sec) when i am trying to get vended object from the remote machine which gone to sleep. Below is the code [...] On which line is the code blocking? You can find out by sampling the process from Activity Monitor or breaking into the process with the debugger. The delay you're seeing is probably the TCP connection timeout. On most systems, it will take about 9 minutes for TCP to give up all attempts to connect and timeout. I would hope that NSConnection would implement its own timeout mechanism as an alternative to allowing TCP to exhaust itself. As near as I can tell from reviewing the documentation, the reply timeout should govern the -rootProxy method. Since you're setting that, then I'm not sure why it's not working. This might be a bug, which you should file at http://bugreport.apple.com . Regards, Ken ___ 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
Re: Long Time Dealy When getting Vended Object
These are the lines of code i got blocked 1. When Remote Machine is not in Network 553 -[PXDistributedObjectsClient serverObjectWithReestablishingConnection] 553 -[PXDistributedObjectsClient serverObject] 553 _CF_forwarding_prep_0 553 ___forwarding___ 553 -[NSDistantObject forwardInvocation:] 553 -[NSConnection sendInvocation:internal:] 553 -[NSConnection sendInvocation:internal:] On 22-Apr-09, at 3:33 PM, Kiran Kumar S wrote: Thanks, Ken for your Reply, Usually we will get time out exception when trying to get vended object that is not available but in the below case i use to get same exception after a long long delay and some times My app crashes Thanks SkiranKumar On 22-Apr-09, at 1:52 PM, Ken Thomases wrote: On Apr 22, 2009, at 1:14 AM, Kiran Kumar S wrote: Really going mad, it is taking long time response when i am trying to get vended Object from the remote machine which doesn't exist in the network. . I am facing same long time delay(more than 60 sec) when i am trying to get vended object from the remote machine which gone to sleep. Below is the code [...] On which line is the code blocking? You can find out by sampling the process from Activity Monitor or breaking into the process with the debugger. The delay you're seeing is probably the TCP connection timeout. On most systems, it will take about 9 minutes for TCP to give up all attempts to connect and timeout. I would hope that NSConnection would implement its own timeout mechanism as an alternative to allowing TCP to exhaust itself. As near as I can tell from reviewing the documentation, the reply timeout should govern the -rootProxy method. Since you're setting that, then I'm not sure why it's not working. This might be a bug, which you should file at http://bugreport.apple.com . Regards, Ken ___ 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/kirankumar.s%40prithvisolutions.com This email sent to kirankuma...@prithvisolutions.com ___ 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
SocketPort allocating
I had Distributed object which can used by any client, i am establishing connection using a port , every thing works fine.My object is vended and the client can use the vended object . But i am getting problem when i restart my server which supplies vended object. When i am restarting sometimes my socket is not get allocated , and this is beecause the socket is using by any of the client, how can i resolve this situation . NSSocketPort *serverPort = [[[NSSocketPort alloc] initWithTCPPort: 3002] autorelease]; aConnection = [[NSConnection alloc] initWithReceivePort:serverPort sendPort:nil]; NSRunLoop *runloop = [NSRunLoop currentRunLoop]; [aConnection setRootObject:[ServerObject sharedServerObject]]; Regards kiran ___ 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
Popups Binding problem
Hi, I have two popups which I want to bind together; the first popup contains a list of Categories, which has an array of reports. The reports array is a content array of the second popup. I want to select a Category in the first popup and get a list of reports in the second popup. When user changes a Category, the popup updates with the corresponding list. When I open the APP, the popups are populated correctly, but the second one (with employees) doesn't update after Category change. Please Suggest me if any ideas Regards SKiran ___ 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 [EMAIL PROTECTED]