【发布时间】:2014-04-23 02:19:33
【问题描述】:
我正在尝试创建一个单例。这组代码旨在建立一个 settingsMAnager 单例。
我正在尝试分配它,但一直抛出错误
它抛出错误 no visible @ interface with NSObject。 声明选择器'alloc'
有人能看出什么问题吗?
提前致谢!
//In my .h file I have
+(settingsManager*)getInstance;
-(void)printSettings;
//In My .m file is----
static settingsManager *theInstance = nil;
//Instance Method
+(settingsManager*)getInstance
{
(theInstance == nil)
{
[[self alloc] init];//Im getting "expression result unused" here
}
return theInstance;
}
-(id)alloc
{
theInstance = [super alloc];<------//getting the big error here
return theInstance;
}
-(id)init
{
if (self = [super init])
{
}
return self;
}
(void)printSettings
{
NSLog(@"Hello");
}
【问题讨论】:
标签: objective-c