Last active
December 26, 2015 16:59
-
-
Save neonichu/7183605 to your computer and use it in GitHub Desktop.
"What is the only* public class in the cocoa frameworks that has no methods of its own?" https://twitter.com/NSLondonMeetup/status/394473852094259200
This file contains hidden or 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
| FindClasses |
This file contains hidden or 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
| #!/bin/sh | |
| FWK_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks" | |
| clang -o FindClasses -std=c99 -framework Foundation FindClasses.m | |
| headers="`find "$FWK_PATH" -name '*.h'`" | |
| for class in `./FindClasses 2>&1|cut -d" " -f4` | |
| do | |
| grep $class $headers >/dev/null 2>&1 | |
| if [ $? -eq 0 ] | |
| then | |
| echo $class | |
| fi | |
| done |
This file contains hidden or 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> | |
| int main(int argc, char *argv[]) { | |
| @autoreleasepool { | |
| int numClasses; | |
| Class * classes = NULL; | |
| classes = NULL; | |
| numClasses = objc_getClassList(NULL, 0); | |
| if (numClasses > 0 ) | |
| { | |
| classes = malloc(sizeof(Class) * numClasses); | |
| numClasses = objc_getClassList(classes, numClasses); | |
| for (int i = 0; i < numClasses; i++) { | |
| unsigned int numMethods; | |
| Method *methods = class_copyMethodList(classes[i], &numMethods); | |
| free(methods); | |
| if (numMethods == 0) { | |
| NSString* className = NSStringFromClass(classes[i]); | |
| if ([className rangeOfString:@"_"].location == NSNotFound) { | |
| NSLog(@"%@", className); | |
| } | |
| } | |
| } | |
| free(classes); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ./find.sh
NSURLSessionDataTask
NSURLSessionUploadTask
NSURLSessionDownloadTask
(and, yes, the answer is semi-wrong because the program runs on OS X and the script examines iOS headers)