id topLayoutGuideObj = objc_msgSend(viewController, @selector(myselector));
\"Too many arguments to function call, expected 0, h
See just a few lines above you referred.
/*
* ...
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*/
You can call it like:
#import <objc/runtime.h>
#import <objc/message.h>
id<MyProtocol> topLayoutGuideObj = ((id (*)(id, SEL))objc_msgSend)(viewController, @selector(myselector));
OR
id (*typed_msgSend)(id, SEL) = (void *)objc_msgSend;
id<MyProtocol> topLayoutGuideObj = typed_msgSend(viewController, @selector(myselector));
I have checked it out, the main problem was as @Jerry Krinock said in comment of accepted answer;