Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id

我们获取全局的AppDelegate的时候,当是ARC的时候,

当我们这样写的时候

AppDelegate *app = [UIApplication sharedApplication].delegate;

会报警告:Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id

对其进行强转一下

AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate;

搞定!!!

你可能感兴趣的:(经验之谈)