NSMachPortDelegate中handleMachMessage的参数类型是什么?

时间:2016-08-22 08:01:44

标签: ios objective-c

我在Xcode中尝试了这些代码,但是在我的控制台中得到了message:4352。 我徘徊参数(void *)msg究竟是什么意思?

- (void)launchThread
 {
 _myPort = [[NSMachPort alloc] init];
 if (_myPort)
 {
    [_myPort setDelegate:self];
    [[NSRunLoop currentRunLoop] addPort:_myPort forMode:NSDefaultRunLoopMode];
    [NSThread detachNewThreadSelector:@selector(LaunchThreadWithPort:)
                             toTarget:self
                           withObject:_myPort];
 }
}

- (void)LaunchThreadWithPort:(id)inData
{
   NSPort *distantPort = (NSPort*)inData;

   [distantPort sendBeforeDate:[NSDate date] msgid:12 components:nil from:nil reserved:123];
}

- (void)handleMachMessage:(void *)msg
{
    NSLog(@"message:%d", *(int *)msg);
}

0 个答案:

没有答案