プロキシ オブジェクトを販売することができません。接続を取得しようとすると、クライアント側でスタックするだけです
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);
}
誰が私が間違っているのか教えてもらえますか?