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.
我是 Xcode 的初学者,但我用其他语言编程过,比如 C++。我试图在我的 ViewContoller.m 文件中有一个全局变量,我可以在所有函数中使用它。我想创建一个存储字符串的全球化可变数组。谢谢你。
如果要在整个应用程序中使用,则在所有类中使用 Shared Instance/Singleton Class,以形成全局变量。
如果要在类中访问,请创建一个属性。这将在您的课堂上通过_propertyName和访问self.propertyName。
_propertyName
self.propertyName
最好使用类的属性,并为此使用 NSNotificationCenter。