appdelegate shared instance delegate
问题 MyAppDelegate *appD; appD = [UIApplication sharedApplication]; if(appD.sw1.on) NSLog(@"It is ON"); else NSLog(@"It is OFF"); Gives no error while compiling. Runs without any warning, but it doesn't work. I dont see what the problem is. ... EDIT: OMG, should have called delegate method too: appD = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 回答1: I recommend you this method to share the app delegate: https://coderwall.com/p/z4h4uw?i=2&p=1&q=&t%5B%5D=%21%21mine&t%5B%5D=%21