在 AppDelegete.m中声明:
+(AppDelegate*) sharedDelegate
{
return(AppDelegate*)[ [UIApplication sharedApplication]delegate];
}
AppDelegate *appDelegate;
appDelegate=[AppDelegate sharedDelegate]; <= warning
但是系统报出警告:"Class method '+sharedDelegate' not found - return type defaults to id"
不知道怎么隐藏这个警告?谢谢
先在 头文件 中声明方法
在使用的地方导入 AppDelegate.h :
AppDelegate *appDelegate;
appDelegate = [AppDelegate sharedDelegate];