Databases Reference
In-Depth Information
objects share a many-to-one relationship between the properties
children
and
parent
. The resulting model looks like this:
Distributed Objects Protocol
When I am working with distributed objects, I prefer to contain the contract
between the client and the server within a protocol. For this application, we
are going to have a few methods that the clients can use to query the server,
but we are not going to have any server to client queries.
The resulting protocol is as follows:
#define kDomainName @
"local."
#define kServiceName @
"_pragProgExample._tcp"
@protocol
PPDistributedProtocol
- (oneway
void
)ping;
- (byref NSManagedObject*)createObject;
- (byref NSManagedObject*)createChildForObject:(byref NSManagedObject*)parent;
- (oneway
void
)deleteObject:(byref NSManagedObject*)object;
- (byref NSArray*)allObjects;
- (byref NSArray*)objectsOfName:(bycopy NSString*)name
withPredicate:(bycopy NSPredicate*)predicate;
@end
When we are working with distributed objects, we need to define how nonscalar
attributes are handled. (These are discussed in depth in Apple's documenta-
tion.) In our protocol, we are passing most of the objects
byref
, which means
an
NSDistantObject
is created on the receiver as a proxy to the object residing
on the server. This is different from
bycopy
, which makes a copy of the object
on the receiving end. One of the interesting differences between these is that
KVO
works across a distributed object when it is passed
byref
. This will be
demonstrated as we build the application.
Search WWH ::
Custom Search