我不确定问题是什么 - 我收到“找不到 Singleton 的接口(interface)声明”, 这里:@implementation Singleton
我收到“Singleton 可能不会响应 +alloc”, 这里:静态单例*共享;
.m 文件
#import "Singleton.h"
@implementation Singleton
+(Singleton *) sharedSingleton
{
static Singleton *shared;
if (!shared) {
shared = [[self alloc] init];
}
return shared;
}
@结束
.h 文件
#import <Foundation/Foundation.h>
@interface Singleton : NSObject {
}
+ (Singleton *)sharedSingleton;
@end
我只想要一个基本的单例类:(它们显示为警告,但如果可能的话我希望它们消失!希望这不是愚蠢的,这是漫长的一天
最佳答案
如果仍然无法删除警告,请尝试清理您的项目 更改您的线路
shared = [[self alloc] init];
至
shared = [[Singleton alloc] init];
关于iphone - 可能不响应+alloc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9425090/