専門家の皆さん、NSThreadで少し問題が発生しています。Xcodeは、「* __NSAutoreleaseNoPool():プールが配置されていない状態で自動リリースされたクラスNSCFStringのオブジェクト0x5694dc0-リークしているだけです」というエラーを出し続けます。
NSAutoreleasePool * pool = [[NSAutoreleasePoolalloc]init];という行でプールを正しく宣言しています。
次に、ループの最後に次を使用します。[プールリリース];
これは、performSelectorInBackgroundとしてデリゲートメソッドを使用しているためですか?stackoverflowに感謝します。
- (void)preFetch { //process filenames to be downloaded and assign types to each one
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *regions = [NSArray arrayWithObjects: @"dr_national", @"ds_ir", @"conus_FL360", @"FL360_conus", @"dr_nw", @"dr_nc", @"dr_ne", @"dr_sw", @"dr_sc", @"dr_se", @"ds_ir_nw", @"ds_ir_nc", @"ds_ir_ne", @"ds_ir_sw", @"ds_ir_sc", @"ds_ir_se", nil];
NSError* error;
for (NSString *regionDir in regions) {
NSLog(@"region now: %@", regionDir); foo = 0;
NSString *regUrl = [NSString stringWithFormat:@"http://someUrl/%@/index.lst", regionDir ];
NSString* text1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:regUrl ] encoding:NSASCIIStringEncoding error:&error];
NSArray *listItems = [text1 componentsSeparatedByString:@"\n"];
for (int k=0; k<[listItems count]; k++) {
if ([[listItems objectAtIndex:k] length] != 0){
NSString *newpath = [NSString stringWithFormat:@"http://someUrl/%@", [listItems objectAtIndex:k]];
NSLog(@"newpath: %@",newpath);
[self performSelectorInBackground:@selector(moveProgressBar) withObject:nil];
[self fetchImages:newpath:type]; //pass multiple arguments to fetchImages, newpath and type
}
}
}
[pool release];
}
- (void)moveProgressBar{
[delegate increaseAmount];
}