Created
April 13, 2014 12:55
-
-
Save satoshin2071/10582968 to your computer and use it in GitHub Desktop.
[objC]文字列からインスタンス生成
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
- (id)createWithClassName:(NSString*)title | |
{ | |
NSString *className = [NSString stringWithFormat:@"%@ViewController",title]; | |
Class aClass = NSClassFromString(className); | |
id instance = nil; | |
if (aClass) { | |
instance = [[aClass alloc]init]; | |
} | |
return instance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment