我在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);
}