Skip to content

Instantly share code, notes, and snippets.

@brentsimmons
Created July 20, 2015 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentsimmons/5ccd357f0fa1486bdc3f to your computer and use it in GitHub Desktop.
Save brentsimmons/5ccd357f0fa1486bdc3f to your computer and use it in GitHub Desktop.
Class is unknown until runtime
// How do you do this in Swift?
- (Class)classToUse {
return [Foo class]; // assume it's something else sometimes
}
- (id)generateThingForString:(NSString *)s {
Class thingClass = [self classToUse];
return [[thingClass alloc] initWithString:s];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment