While debugging just a few small problems, there is a piece of code to reuse
NSString *key =@"cfbundleversion"; //Remove the version number of the last-used software stored in the sandboxNsuserdefaults *defaults =[Nsuserdefaults Standarduserdefaults]; NSString*lastversion =[Defaults Stringforkey:key]; //Remove the current version numberNSString *currentversion =[NSBundle Mainbundle].infodictionary[key]; Etlog (@"%@===%@=================", Self.window,application.keywindow); if([lastversion isequaltostring:currentversion]) {Application.keyWindow.rootViewControl Ler=[[Ettarbarcontrollor alloc] init]; } Else{Application.keyWindow.rootViewController=[[Newfeatureviewcontroller alloc] init]; [Defaults setobject:currentversion Forkey:key]; [Defaults synchronize]; }
It was supposed to be extracted and then used in the tool class [uiapplication sharedapplication]. Keywindow. Rootviewcontroller replaces the original self. Window. Rootviewcontroller, but found that with the real machine debugging when the black screen, not normal display, I felt strange at that time, is not the location of the code to change, and then I put appdelegate self. Window. Rootviewcontroller Replace
application. Keywindow. Rootviewcontroller, found or not, I that depressed ah, later the same code I run on the virtual machine, Mom eggs, can run, I must be on the real machine debugging, so, I went back to the real machine, I application. Keywindow and self. Window Print out, note that this is on the real machine and found appapplication. Keywindow is empty, self. window has value, so I'm [self. Window makekeyandvisible]; put to call application. Keywindow in front, incredibly shameful have value, real machine can also run, but do not know what reason, may be application life cycle about put, that friend know what reason to say ah, on such a inexplicable bug roughly fix.
OC Learning Path----Application.keyWindow.rootViewController and Self.window.rootViewController and [Self.window Makekeyandvisible]; Small discoveries