LoginSignup
3
3

More than 5 years have passed since last update.

文字列からクラスのインスタンスを生成する。

Last updated at Posted at 2012-10-17

Hogeというクラスのインスタンスを生成する場合の例。

Sample

Class aClass = NSClassFromString(@"Hoge");
id obj = [[aClass alloc] init];
if ([obj isMemberOfClass:[Hoge class]]) {
    NSLog(@"Hogeだよ");
}

3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3