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

ARC的时候我们获取全局的AppDelegate

1
AppDelegate *app = [UIApplication sharedApplication].delegate;

会报警告:

1
Initializing 'AppDelegate *__strong' with an expression of incompatible type 'id<UIApplicationDelegate>

对其进行强转一下

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

就好了