iOS开发笔记--声明全局变量

来源:互联网 发布:let it go let it be 编辑:程序博客网 时间:2024/06/11 09:42

iOS开发时候,设置全局变量和调用的方法:
在AppDelegate.h文件中设置全局变量:

@interface ***AppDelegate{NSString *myName;}@property (nonatomic, retain) NSString *myName;@end

在AppDelegate.m文件中实现全局变量:

@synthesize myName;

假如在 CallBack页面调用,在CallBack.m中包含AppDelegate.h文件,并定义一个代理实例,如下
#import "AppDelegate.h"-(void)****{AppDelegate *myDelegate = [[UIApplication sharedApplication] delegate];myDelegte.myName = @"123 ";}



原创粉丝点击