如何在main.m
文件中声明变量以使其在所有类中都可用?
如果我只是在main
函数中声明它,编译器说它在类方法中未声明.
我必须在这样的对象中声明它吗?
@public
type variable;
Run Code Online (Sandbox Code Playgroud) 我写了一个使用myarray的方法,在同一个类中定义.当我使用count时它总是返回0.当我使用:
printf("%d", [myarray count]);
Run Code Online (Sandbox Code Playgroud)
编译说:
Format '%d' expetcs type 'int', but argument 2 has type 'NSUInteger'
Run Code Online (Sandbox Code Playgroud)
为什么?