メソッドが呼び出された後に配列を解放する正しい方法を見つけるのが苦労しています。 I私は私の方法でacheiveしようとしているものを達成するためのより良い方法があるかどうか疑問:メモリ管理に苦しんで配列メソッドを作成
- (NSArray *) setupDetailArray : (NSString *) selectedCategory {
// Load .plist file
NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
// Load .plist into a new dictionary
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
// Drill down to next level
NSArray *faceSelection = [[NSArray alloc] initWithArray:[dict objectForKey:detailTitle]];
[dict release], dict = nil;
// Set up link to App Delegate
UltimateRageAppDelegate *dataCenter = (UltimateRageAppDelegate *) [[UIApplication sharedApplication] delegate];
dataCenter.faces = [[NSMutableArray alloc] init];
// Set app delegate faces to array
dataCenter.faces = faceSelection;
[dataCenter.faces release];
return faceSelection;
// [faceSelection release], faceSelection = nil; ??????
}
そして、私は私のアプリケーションは、ここでのメモリをリークしている
// If faceArray is empty, create it
if (faceArray == nil)
faceArray = [self setupDetailArray:detailTitle];
...
のviewDidLoad
の私のメソッドを呼び出すと、私は一度やったらすべてを解放する方法を本当に探しています。
よろしくお願いいたします。私は完全に新しいので、私はその文書と闘う。私はいつかそれが意味をなさないと信じています! – squarefrog
あなたはそれを何度も何度も読んで、可能な限り多くの例を見つけようとする必要があります。結局それは意味をなさない! –
自信を持って投票してくださったNick Bull! – squarefrog