簡単なクラスは次のとおりです。
#import "One.h"
#import "Two.h"
@implementation DataFileRegistrar
static NSMutableDictionary *elementToClassMapping;
+ (void)load
{
[self registerClass:[One class] forElement:@"one"];
[self registerClass:[Two class] forElement:@"two"];
}
+ (void)registerClass:(Class)class forElement:(NSString *)element
{
if (!elementToClassMapping) {
elementToClassMapping = [NSMutableDictionary dictionaryWithObject:class forKey:element];
} else {
[elementToClassMapping setValue:class forKey:element];
}
}
+ (id)classForElement:(NSString *)element
{
return [elementToClassMapping valueForKey:element];
}
@end
問題は、このコンパイラメッセージです。
objc[7172]: Object 0x6840720 of class __NSCFDictionary autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
何が起こっているのかアイデアはありますか?
基本的に、いくつかのクラスメソッドと1つの静的ディクショナリを備えた単純なクラスが必要です。インスタンス化せずに常に使用されます。アプリの起動直後にいくつかの用途に使用したいので、メモリを解放したいと思います。ARCがこれを処理できると思いました。