我想對自己做一些關於全局變量的命令。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