我无法出售代理对象,它只是在尝试连接时卡在客户端
NSConnection *conn = [NSConnection connectionWithRegisteredName:@"server" host:nil];
这是我注册连接和出售对象的方法
//server
-(void)initServer {
NSConnection * connection = [[NSConnection alloc]init];
MZRemoteObject * obj = [[MZRemoteObject alloc]init];
obj.message = @"hello world";
[connection setRootObject:obj];
if([connection registerName:@"server"]== NO){
NSLog(@"error Register Server");
}
NSLog(@"Registered Server");
}
客户端(获取出售的对象)
- (void)recieveMessage {
NSDistantObject *proxy;
NSConnection *conn = [NSConnection connectionWithRegisteredName:@"server" host:nil];
if (!conn) {
NSLog(@"conn recieve message error");
}
proxy = [conn rootProxy];
MZRemoteObject * obj =(MZRemoteObject*)proxy;
if (!proxy) {
NSLog(@"proxy,recieve message error");
}
NSLog(@"----%@",obj.message);
}
谁能告诉我我做错了什么?