• 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
D.O. won't pass NSBezierPath ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

D.O. won't pass NSBezierPath ???


  • Subject: D.O. won't pass NSBezierPath ???
  • From: Per Persson <email@hidden>
  • Date: Wed, 2 May 2001 17:05:06 +0200

Hi,
I have a background in c-programming and lately I've spent some time trying to get into the Obj-C/Cocoa way of life and so far the sun has been shining on my journey... except for this little issue:

I want to send an NSBezierPath object from one app to another to have it displayed. Making a connection and sending e.g. an NSString object works fine but sending an NSBezierPath fails miserably... Either the 'send:' method works by pure luck or there is some fundamental difference between an NSString and NSBezierPath.

Could anyone enlighten me?!

/Per

Excerpts from the code:
---- Protocol ----

@protocol ConnectProtocol
- (void) send:(NSString *)message;
- (void) displayGraph:(NSBezierPath *)graphPath;
@end

---- Receiver(server) -----

#import <Cocoa/Cocoa.h>
#import "connectProtocol"
@interface ReceiverObject : NSObject <ConnectProtocol>
{
IBOutlet id receiverOutlet;
NSConnection *myConnection;
}
/* Protocol methods */
- (void) send:(NSString *)message;
- (void) displayGraph:(NSBezierPath *)graphPath;
@end

#import "ReceiverObject.h"
#import "ReceiverView.h"

@implementation ReceiverObject
- (void)awakeFromNib
{
myConnection = [[NSConnection defaultConnection] retain];
[myConnection setRootObject:self];

if([myConnection registerName:@"Receiver"] == NO) {
NSLog(@"Error registering %s\n", @"Receiver");
}
}
- (void) send:(NSString *)message
{
if ([message isEqualTo:@"1"]) {
NSLog(@"Got 1\n");
[receiverOutlet setReceiverViewPath:[NSBezierPath bezierPathWithRect:NSMakeRect(10,10,20,30)]];
} else {
NSLog(@"Got 0\n");
[receiverOutlet setReceiverViewPath:[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(10,10,20,30)]];
}
}
- (void) displayGraph:(NSBezierPath *)graphPath
{
[receiverOutlet setReceiverViewPath:graphPath];
}
@end


---- Sender(client) -----
#import <Cocoa/Cocoa.h>
#import "connectProtocol"

@interface SenderObject : NSObject
{
id theProxy;
}
- (IBAction)plot:(id)sender;
- (IBAction)set:(id)sender;
@end

#import "SenderObject.h"
@implementation SenderObject
-init
{
/* Set up connection */
theProxy = [[NSConnection rootProxyForConnectionWithRegisteredName:@"Receiver" host:nil] retain];
/* Check availability */
if (theProxy) {
printf("Connected to Receiver\n");
} else {
printf("** NOT ** Connected to Receiver\n\n");
}
/* Set up communication rules... */
[theProxy setProtocolForProxy:@protocol(ConnectProtocol)];
return self;
}

- (IBAction)plot:(id)sender
{
NSBezierPath *aPath=[NSBezierPath bezierPath];
[aPath moveToPoint:NSMakePoint(0,0)];
[aPath lineToPoint:NSMakePoint(60,60)];
[aPath moveToPoint:NSMakePoint(0,60)];
[aPath lineToPoint:NSMakePoint(60,0)];
[theProxy displayGraph:aPath];
}

- (IBAction)set:(id)sender
{
[theProxy send:@"1"];
}
@end


  • Follow-Ups:
    • Re: D.O. won't pass NSBezierPath ???
      • From: Mike Ferris <email@hidden>
    • Re: D.O. won't pass NSBezierPath ???
      • From: Aki Inoue <email@hidden>
  • Prev by Date: Re: NSOpenPanel and New Folder button
  • Next by Date: Re: Cocoa, Java and C
  • Previous by thread: Re: NSOpenPanel and New Folder button
  • Next by thread: Re: D.O. won't pass NSBezierPath ???
  • Index(es):
    • Date
    • Thread