【发布时间】:2010-10-25 15:39:06
【问题描述】:
我可以像这样定义全局字符串:
// .h
extern NSString * const myString;
// .m
NSString * const myString = @"String";
现在我需要类似地定义 UIcolor,我该怎么做?
我正在尝试:
// .h
extern UIColor * const myColor;
// .m
UIColor * const myColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
但这不起作用,我收到error: initializer element is not constant
谢谢
【问题讨论】:
-
不知道发生这种情况的确切原因,但this question 可能会帮助您找到解决方案。
-
类别(来自已接受答案中的链接答案)在这里是多余的。请看这个问题:创建字典对象:stackoverflow.com/questions/3855556/…
标签: iphone objective-c constants