私はC、Obj-C、iPhoneの初心者で、多くの用語が使用されています。iPhoneでメモリがリークしている:(
以下のコードは、検索フィールドとテーブルを含むnibを呼び出すメソッドです。テーブルは、以下の 'theList'のために作成された配列から検索されます。 NSDictionary * theItem = [NSDictionary dictionaryWithObjectsAndKeys:clientName、@ "Name"、clientId、@ "Id"、nil];しかし、私は理由を把握することができません: 'Instruments'を使用して、私はリークをラインで取得しています : (
私はそれはおそらく答えが難しい質問ですが、 1つはどんな助けでもかまいません!
- (void)editClient:(id)sender {
if (pickList == nil) {
pickList = [[PickFromListViewController alloc] initWithNibName:@"PickList" bundle:nil];
}
TimeLogAppDelegate *appDelegate = (TimeLogAppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableArray *theList = [[NSMutableArray alloc] init];
int i;
for (i=0;i < [appDelegate.clients count];i++) {
Client *thisClient = [appDelegate.clients objectAtIndex:i];
NSString *clientName = [[NSString alloc] initWithString: thisClient.clientsName];
NSNumber *clientId = [[NSNumber alloc] init];
clientId = [NSNumber numberWithInt:thisClient.clientsId];
NSDictionary *theItem = [NSDictionary dictionaryWithObjectsAndKeys:clientName,@"Name",clientId,@"Id",nil];
[theList addObject:theItem];
theItem = nil;
[clientName release];
[clientId release];
}
[pickList createSearchItems:theList :NSLocalizedString(@"Client",nil)];
[theList release];
appDelegate.returningID = [NSNumber numberWithInt: projectsClientsId];
[self.navigationController pushViewController:pickList animated:YES];
}
ありがとうございます!
お時間をありがとう!私はあなたが示唆したとおりに実際にそれを持っていましたが、そのコードを変更して問題を解決できるかもしれないと考えました。あなたの提案通りに戻ってきましたが、同じリーク結果があります。問題は、呼び出されたペン先の中にあると思いますか? – Chris
あなたは何を得ているのですか? – stefanB
NSCFDictionary、NSCFArray&GeneralBlock-16があり、その1行を参照しています。あなたが見る通り、私はメソッドの最後に新しいViewControllerを押します。そこにはMutableCopyを使って2つのMutableArraysを作成してTableViewの検索を実行します - 私は深いコピーを実行していませんので、MutableCopiesはまだ同じオブジェクトペア?これらの2つの配列は、一度終了したViewController内で明らかに解放されます。あなたの時間と助けにもう一度感謝します。 – Chris