26

値がインスタンス化する必要のあるClass[MyClass]の名前である文字列があり、MyClassには次のメソッドがあります。

 -(void)FunctionInClass;

NSClassFromStringというメソッドを使用してMyClassをインスタンス化しています。知りたい

1) what does NSClassFromString return?? 
2) what is id? 
3) How to call method -(void)FunctioninClass which is in MyClass using the instance.

どのように進めればよいですか、Objective-C for iPhoneアプリでやっていますか?

4

2 に答える 2

56

1) what does NSClassFromString return??

クラスを返します。つまり、詳細についてはMac Dev Center のドキュメント[[NSClassFromString(@"MyClass") alloc] init];を 参照してください。

2) what is id?

http://www.otierney.net/objective-c.html#idtypeを参照

3) How to call method -(void)FunctioninClass which is in MyClass using the instance.

id myclass = [[NSClassFromString(@"MyClass") alloc] init];
[myclass FunctioninClass];
于 2010-02-09T03:55:10.473 に答える