我已經注意到這個主題的幾個其他線程,並試圖包裝我的線程代碼: NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; [游泳池釋放];爲什麼我越來越*** _NSAutoreleaseNoPool():NSCFDictionary類的對象0x97480b0 autoreleased沒有到位的池 - 只是漏
但是錯誤仍然存在。
我正在使用靜態方法來實例化單詞字典。 下面是一些代碼:
-(id)init
[NSThread detachNewThreadSelector:@selector(loadDictionary:) toTarget:[IntroScreen class] withObject:nil];
[NSThread setThreadPriority:1.0];
return self;
}
+(void)loadDictionary:(id)param
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[SimpleAudioEngine sharedEngine] preloadEffect:@"click.wav"];
[[SimpleAudioEngine sharedEngine] preloadEffect:@"pop.wav"];
[[SimpleAudioEngine sharedEngine] preloadEffect:@"dink.wav"];
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"musicloop.wav"];
[WordDictionary configDictionary];
[pool release];
}
+(void)configDictionary
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Serializer * mySerializer = [[Serializer alloc] init];
[WordDictionary setDictionary:[mySerializer readApplicationPlist:@"x"]];
NSString * string;
NSString *filePath = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"x.txt"];
NSString *info = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSArray *arrayOfLines = [info componentsSeparatedByString:@"\r\n"];
[WordDictionary setDictionary:[[NSMutableDictionary alloc] init]];
[NSMutableDictionary dictionaryWithContentsOfFile:filePath];
int len = [arrayOfLines count];
for(int i = 0; i < len; i++)
{
string = [arrayOfLines objectAtIndex:i];
NSString * blankString = [NSString stringWithString:@""];
[[WordDictionary dictionary] setObject:blankString forKey:string];
double calc = ((double)i/(double)len) * 100.0;
[WordDictionary setProgress:(int)calc];
}
[mySerializer writeApplicationPlist:[WordDictionary dictionary] toFile:@"s"];
[WordDictionary setProgress:100];
[pool release];
}
有什麼我應該知道如何使用新的選擇線程靜態類的方法?
感謝您的幫助