Last active
August 29, 2015 14:07
-
-
Save interstateone/2bdcae4dead0f59470a6 to your computer and use it in GitHub Desktop.
Comparing the output of protocol_getMethodDescription and _protocol_getMethodTypeEncoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
const char *_protocol_getMethodTypeEncoding(Protocol *, SEL, BOOL isRequiredMethod, BOOL isInstanceMethod); | |
@protocol Tester <NSObject> | |
@required | |
- (BOOL)testDictionary:(NSDictionary *)dictionary error:(NSError **)error; | |
@end | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
struct objc_method_description description = protocol_getMethodDescription(@protocol(Tester), @selector(testDictionary:error:), YES, YES); | |
NSLog(@"%s", description.types); | |
// Outputs c32@0:8@16^@24 | |
const char *descriptionString = _protocol_getMethodTypeEncoding(@protocol(Tester), @selector(testDictionary:error:), YES, YES); | |
NSLog(@"%s", descriptionString); | |
// Outputs c32@0:8@"NSDictionary"16^@24 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment