0
我想調用AppDelegate.m中另一個類的方法。我已經做了以下情況:來自AppDelegate的調用方法無法識別的選擇器發送到實例錯誤
- 在MyClass.h,我有
-void testMethod
- 在AppDelegate.m,我有
#import "MyClass.h"
MyClass * myClassInstance = [[MyClass alloc] init];
[myClassInstance testMethod]
- 在AppDelegate.h,我有也進口
#import "MyClass.h"
我想我已經做了一切這個問題的答案建議:calling a method inside someClass from AppDelegate Objective-C IOS
但我仍然收到「無法識別的選擇器發送到實例」錯誤?
什麼是缺失?
在此先感謝。
用完整準確的錯誤信息更新您的問題。您已經省略了郵件的導入部分。用導致錯誤的確切代碼行更新您的問題。 – rmaddy
你忘了在void的旁邊添加括號嗎?例如, - (void)testMethod –
@Ke Cheng您需要在m文件中實現此方法。查看本教程http://roadfiresoftware.com/2014/06/how-to-implement-methods-in-objective-c/ – bazyl87