Re: DO: (bycopy NSArray*) not making copies
Re: DO: (bycopy NSArray*) not making copies
- Subject: Re: DO: (bycopy NSArray*) not making copies
- From: Chris Kane <email@hidden>
- Date: Wed, 15 Jun 2005 12:46:49 -0700
The issue almost certainly lies with the objects in the array.
NSCopying is not pertinent to "bycopy" over D.O., but archiving is.
You should look at the -replacementObjectForPortCoder: method on
NSObject, and implement it in your identifier object class. How you
do that is somewhat a matter of taste, but it would look something
like this:
- (id)replacementObjectForPortCoder:(NSPortCoder *)encoder {
return [encoder isByref] ? (id)[NSDistantObject
proxyWithLocal:self connection:[encoder connection]] : self;
}
Note that here the default is "bycopy" behavior, if the byref keyword
is not present in the method declaration on the parameter being
serialized by the NSPortCoder. If byref is present, a proxy will get
sent over the wire, if bycopy is present or neither is present, then
"self" will get archived and sent. If you want the objects of that
class to always go bycopy, and ignore any keyword (as some classes
do, and that's their choice), then implement the method to just
return self.
And of course the class has to implement NSCoding, and, for D.O.
still, non-keyed coding at that.
Chris Kane
Cocoa Frameworks, Apple
On Jun 9, 2005, at 4:44 PM, James Bucanek wrote:
Greetings,
I've got a distributed objects problem. I'm sending an array of
"identifier" objects (most of them are just strings, but some are
combinations of strings and serial numbers, record IDs, etc.).
When they get to the server thread they need to be effecient, so I
need them to be local copies of the ID objects, not proxies to the
ID objects in the client. I've implemented NSCopying protocols on
all of these objects, most of which are very simple subclasses of
NSObject. I've defined protocols for all of my setter methods, and
used the bycopy keyword:
- (oneway void)appendRecordWithIdentifierList:(bycopy in
NSArray*)identifierList;
Yet, not matter what I do I cannot get DO to copy the individual
objects in the array. It seems only to want to copy the NSArray
itself, filling it with NSDistantObjects to the originals in the
client. The server starts calling [proxy isEqual:someOtherID], and
a flurry of messages and proxy objects go flying back and forth
between the client and server. It's a mess.
How can I get DO to copy the NSArray AND make copies of all of the
object in the array?
--
James Bucanek <mailto:email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden