陈斌彬的技术博客

Stay foolish,stay hungry

Assigning to 'AppDelegate *' From Incompatible

Assigning to ‘AppDelegate *’ from incompatible type 'id<UIApplicationDelegate>'

down vote

favorite

In my project it says Assigning to ‘AppDelegate *’ from incompatible type ‘id’.

May I know what exactly this? Why this warning occurred?

I have declared in .m

AppDelegate *appdev;

and in viewDidLoad

{
    appdev = [[UIApplication sharedApplication]delegate];     <= warning here
}

I want to hide this warning. What should I do? Thanks in advance.


since you know they equal, add a cast to let the compiler know

appdev = (AppDelegate*)[[UIApplication sharedApplication]delegate];