Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
i want to access variable in all views ,so how can i declare it ....
如果你真的想要一个全局变量,那么在你所有的视图控制器#included的头文件中,把这个:
extern int MyVariable;
然后在一些 .m 文件(正是一个)中,输入:
int MyVariable = 0;
但是请查看有关单身人士的答案。
看看Singletons看看这里和这里