2016-09-23 54 views
1

初始化xcode 8中的appdelegate對象,引發警告。有什麼不對的語法如下初始化xcode 8中的Appdelegate對象

AppDelegate *del=[[UIApplication sharedApplication]delegate]; 
+7

它拋出什麼警告? AppDelegate是你自己的'UIAppDelegate'子類嗎?然後'AppDelegate * del =(AppDelegate *)[[UIApplication sharedApplication] delegate];'可以解決這個問題,但如果它不是'AppDelegate'對象,它可能會破壞它。 – Larme

回答

0

我給你另一種選擇使用的appdelegate對象和decalre它appdelegate.h文件中像這樣

#define theAppDelegate \ 
((AppDelegate *)[UIApplication sharedApplication].delegate) 

希望這個作品罰款