Skip to content

Instantly share code, notes, and snippets.

@JadenGeller JadenGeller/Random Class.m
Last active Aug 29, 2015

Embed
What would you like to do?
Random Objective-C Class Returning Function
#import <objc/runtime.h>
Class randomClass(){
int numClasses = objc_getClassList(NULL, 0);
Class *classes = calloc(sizeof(Class), numClasses);
objc_getClassList(classes, numClasses);
Class randomClass = *(classes + arc4random_uniform(numClasses));
free(classes);
return randomClass;
}
id randomInstance(){
return [[randomClass() alloc]init];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.