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.
すべてのビューで変数にアクセスしたいので、どうすれば宣言できますか....
本当にグローバル変数が必要な場合は、すべてのView Controllerに#includeされているヘッダーファイルに、次のように記述します。
extern int MyVariable;
次に、いくつかの.mファイル(正確に1つ)に次のように入力します。
int MyVariable = 0;
しかし、シングルトンについてのその答えをチェックしてください。
シングルトンをご覧くださいこことここを参照してください