我刚刚更新了我的
Xcode副本,发现我现在有很多警告.我正在努力让以下一个整理出来:
ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate];
导致此警告:
Initializing
ObAppDelegate *__strong
with an expression of
incompatible typeid<UIApplicationDelegate> _Nullable
有人能指出我正确的方向来修复这个警告吗?有关信息,这是问题行之前使用的相关代码:
- (NSManagedObjectContext *) managedObjectContext { return [(ObAppDelegate *) [[UIApplication sharedApplication] delegate] managedObjectContext]; }
解决方法
你有:
ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate];
这会发出警告:
Initializing
ObAppDelegate *__strong
with an expression of incompatible typeid<UIApplicationDelegate> _Nullable
重写为:
ObAppDelegate *appdelegate = (ObAppDelegate*)[[UIApplication sharedApplication]delegate];
这将消除警告.