0

So, I have an iOS 9 App that starts a NSOperation extended class and that class' main method it executes a NSRunLoop. I also have implement handleMessage successfully, that is, when I send some parameters to the NSMachPort, it kind of works...

This is the sender:

NSMachPort *rcPort = ((AppDelegate *)[UIApplication sharedApplication].delegate).rController.serverPort;
NSMutableArray *myarray = [NSMutableArray array];
[myarray addObject:@"hello"];

[rcPort sendBeforeDate:[NSDate distantFuture] msgid:666 components:myarray from:nil reserved:0];

My handleMessage does trigger, and I easily get the msgid

- (void)handleMachMessage:(void *)msg {

    NSLog(@"got a message");
    mach_msg_header_t *msg_t = msg;
    NSLog(@" %d ", msg_t->msgh_id);
}

My question is:

I do get the msgid (666), how do I get at the "components" part in handleMachMessage ? I have searched high-and-low, and I cannot find any references or code samples. It seems that handleMachMessage's msg parameter is only a mach_msg_header_t type, however, if I am able to add a "payload", why can't I get access to the said payload in my handleMachMessage?

geekyaleks
  • 1,281
  • 3
  • 18
  • 29
  • Why don't you check the definition of `mach_msg_header_t`. If any additional information you get. Is the type casting from `void *`. Is it possible to cast it to other type. – Sachin Vas Oct 18 '16 at 14:04
  • Unfortunately, the header is all it is - a header... This is mach_msg_header_t typedef struct { mach_msg_bits_t msgh_bits; mach_msg_size_t msgh_size; mach_port_t msgh_remote_port; mach_port_t msgh_local_port; mach_port_name_t msgh_voucher_port; mach_msg_id_t msgh_id; } mach_msg_header_t; – geekyaleks Oct 18 '16 at 14:07

0 Answers0