我想对自己做一些关于全局变量的命令。c目标c中的全局变量
如果我在我的.m文件
int ran //is it global? every class can see it ? @implementation @end
写,如果我在我的.h文件中写这:
int ran //is it global to any other class that include this .h ? @interface { }
如果我在我的.h写这个文件:
extern int ran //is it global to any other class that include this .h ? @interface { }
如果我在我的.h文件中写这:
@interface { int ran //can every other class that include it can see it ? }
AND
有关@interface
,每一件事情,在界面上,只有这门课吗? 那么在@interface中*NSString
呢?它只属于那个类吗?当包含这个.h时,我可以使用它吗?或者是否必须让该类的对象才能看到它?
什么是最好的方式来放置一个原语的全局变量,只有我的班级会看到它,并可以使用它?
谢谢大家。换句话说,如果我需要一个全局性的外部类,我会做“外部”,如果我需要一个变量是全球内部类只有我做“静态”诠释?因为人们警告我静静的开始 – Curnelious 2012-02-09 14:18:08