AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate> { BOOL isApnsRun; } @property (strong, nonatomic) UIWindow *window; @propertyBOOL isApnsRun; @end
AppDelegate.m
@implementation AppDelegate @synthesize isApnsRun; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. isApnsRun = true; returnYES; }
以上是完成定义,也可以是单独的文件用来保存这些定义;
在其它文件中调用时,先要引用上面的定义文件(#import "AppDelegate.h"),然后
AppDelegate *appDelegate=[[UIApplicationsharedApplication] delegate]; if (appDelegate.isApnsRun==true){ // }