iOS アプリのメモリ管理に少し問題があります。XML をロードし、この XML のすべての値を特定のオブジェクトに設定します。今、私の問題は、この XML の 15 ~ 20 回のリロードごとに XML をリロードするときです。解析時にアプリがクラッシュします。これはパーサーのサンプルです。
編集:NSZombieが無効になっている場合、NSZombieが有効になっている場合のエラーは次のとおりです。エラーメッセージは表示されませんでした。-[CFNumber 保持]: 割り当て解除されたインスタンスに送信されたメッセージ
手伝ってくれてありがとう。
編集:
私のコードの冒頭:
- (id)init
{
self = [super init];
if (self) {
TheObjects *theObjects = [[TheObjects alloc] init];
[self parse];
}
return self;
}
- (void) reload{
reload = YES;
TheObjects *theTmpObjects = [[TheObjects alloc] init];
[self parse];
}
- (void)parse{
for (id xmlOBject in xmlObjects){
MyObject *object = [[MyObject alloc] init];
object.number1 = [NSNumber numberWithInt:1];
object.number2 = [NSNumber numberWithInt:2];
object.number3 = [NSNumber numberWithInt:3];
if (reload)
[theTmpObjects.objects addObject:object];
else
[theObjects.objects addObject:object];
[object release];
}
//later in my code
TheObjects *localTheTmpObjects = nil;
if (reload){
localTheTmpObjects = theObjects;
theObjects = theTmpObjects;
}
if ([delegate respondsToSelector:@selector(finished:)]){
[delegate performSelector:@selector(finished:) withObject:theObjects];
}
if(reload)
[localTheTmpObjects release];
}