例: 定义和使用一个全局变量"isLogin"
AppDelegate.h
@interface AppDelegate :UIResponder <UIApplicationDelegate>
@property (strong,nonatomic)UIWindow *window;
@propertyBOOL isLogin;
@end
AppDelegate.m
@implementation AppDelegate
@synthesize window =_window;
@synthesize isLogin;
@end
那么在其他的class里,则可以通过下列代码调用全局变量
AppDelegate *delegate=(AppDelegate*)[[UIApplicationsharedApplication]delegate];
delegate.isLogin=YES;
ios 全局变量的 定义使用
最新推荐文章于 2020-08-14 10:55:29 发布