【发布时间】:2013-02-16 20:16:53
【问题描述】:
我想在我的 iOS 应用程序的 Constants Singleton 类中设置我的全局常量值,以便任何导入常量的类都可以使用这些值。
但是,在这个想法玩了几个小时之后,我仍然无法实现它。
在我的 Constants.m 文件中
@interface Constants()
{
@private
int _NumBackgroundNetworkTasks;
NSDateFormatter *_formatter;
}
@end
@implementation Constants
static Constants *constantSingleton = nil;
//Categories of entries
typedef enum
{
mapViewAccessoryButton = 999
} UIBUTTON_TAG;
+(id)getSingleton
{
.....
}
我有另一个类 MapViewController,我在其中引用了常量单例,我试图访问这样的枚举
myDetailButton.tag = self.constSingleton.UIBUTTON_TAG.mapViewAccessoryButton;
但是,这不起作用。我无法访问 mapviewcontroller 中的 UIBUTTON_TAG
有人有什么建议吗?
谢谢
【问题讨论】:
标签: ios enums singleton global-variables