IDE: VS 2015
Version: 8.4.96.2027
Target (If relevant): iOS
Description:
iOSTest2.zip (107.5 KB)
public class TestClass {
private int mTagValue;
public TestClass(int tag){
mTagValue = tag;
}
public void doSth() {
NSLog("doSth: " + mTagValue);
}
}
[UIApplicationMain, IBObject]
class AppDelegate : IUIApplicationDelegate
{
public UIWindow window { get; set; }
// Ensure the obj won't be deallocated
private TestClass mRef;
public BOOL application(UIApplication application) didFinishLaunchingWithOptions(NSDictionary launchOptions)
{
window = new UIWindow(UIScreen.mainScreen().bounds);
window.rootViewController = new UIViewController withNibName(null) bundle(null);
window.makeKeyAndVisible();
mRef = new TestClass(999);
// Exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TestClass doSth]: unrecognized selector sent to instance 0x7fcd62e01210'
dispatch_async(dispatch_get_main_queue(), mRef.doSth);
return true;
}