Global int variable objective c

后端 未结 4 1140
误落风尘
误落风尘 2020-12-01 22:31

I want to declare a static int variable in one class and have access to it in every other class. What is the best way to do this?

4条回答
  •  难免孤独
    2020-12-01 23:00

    That breaks some patterns, I'd not use it.

    Anyway, if you declare a property in your app delegate then you can call:
    [[NSApp delegate] myVar] anywhere.

    How exactly do you intent to use this variable?

提交回复
热议问题