本文介绍了在Objective-C中,你如何声明/使用全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究这个问题很长一段时间,我似乎无法找到这个问题的答案。我对iPhone编程相当陌生,所以很抱歉,如果这是一个愚蠢的问题。如果任何人只是具体的代码来发布如何做这件事,这将是非常有益的。

解决方案

Objective-C是一个C的超集,所以只需要用C方法:

  int globalX = 100; 

和头文件:

  extern int globalX; 


I have been researching this problem for a long time, and I can't seem to find the answer to this question. I am fairly new to iPhone programming, so sorry if this is a stupid question. If anyone has just specific code to post showing how this can be done, that will be very helpful.

解决方案

Objective-C is a superset of C, so just do it the C way:

int globalX = 100;

And header file:

extern int globalX;

这篇关于在Objective-C中,你如何声明/使用全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 16:10
查看更多