Reputation: 5970
I have just updated my copy of Xcode and find that I now have lots of warnings. I am struggling to get the following one sorted out though:
ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate];
causes this warning:
Initializing
ObAppDelegate *__strong
with an expression of incompatible typeid<UIApplicationDelegate> _Nullable
Can anyone point me in the right direction to fix this warning? For information this is the related code used prior to the problem line:
- (NSManagedObjectContext *) managedObjectContext {
return [(ObAppDelegate *) [[UIApplication sharedApplication] delegate] managedObjectContext];
}
Upvotes: 8
Views: 8873
Reputation: 535202
You have:
ObAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate];
This will give a warning:
Initializing
ObAppDelegate *__strong
with an expression of incompatible typeid<UIApplicationDelegate> _Nullable
Rewrite as:
ObAppDelegate *appdelegate = (ObAppDelegate*)[[UIApplication sharedApplication]delegate];
That will eliminate the warning.
Upvotes: 30