NSMutableArrayであるインスタンス変数があります
@interface SummaryWindowController : NSWindowController {
NSMutableArray *aBuffer;
NSMutableArrayは、次のメソッドを使用して設定されます(このオブジェクトを初期化したオブジェクトから呼び出されます)。
- (void)setGlobalStatusArray:(NSMutableArray *)myArray
{
if (!aBuffer) {
[myArray retain];
NSLog(@"aBuffer not init , alloc init now");
aBuffer = [[NSMutableArray alloc] initWithArray:myArray];
}
NSLog(@"--> Received buffer: %@",aBuffer);
}
NSLogは、そのメソッドが実行されるときに配列の内容を表示します。
2011-08-18 16:00:26.052 AppName[74751:1307] --> Recievied buffer: (
{
discription = DiskUsage;
menu = "<NSMenuItem: 0x1005116e0 Hardware Status>";
status = Warning;
},
しかし、このインスタンス変数を使用する私のメソッドでは、それはもはや初期化されていないようです
- (IBAction)refreshButtonClicked:(id)sender
{
NSLog(@"The user has clicked the update button");
if (!aBuffer) {
NSLog(@"refresh button not init");
}
NSLog(@"Buffer is currently:%@",aBuffer);
}
この時点で、次のNSLogが表示されます。
2011-08-18 16:04:25.301 AppName[74829:1307] The user has clicked the update button
2011-08-18 16:04:25.303 AppName[74829:1307] refresh button not init
2011-08-18 16:04:25.304 AppName[74829:1307] Buffer is currently:(null)
aBufferが(自動?)リリースされたことを私に示すのはどれですか?
なぜこれがこれを行うのか、何か考えはありますか?最初は、2つの異なるオブジェクトがあると思いました。1つは、元のコントローラーからNSWindowControllerを初期化して作成したものです。
@interface AppName_AppDelegate : NSObject
NSMutableArray *globalStatusArray;
@implementation AppName_AppDelegate
if ( summaryWindow ) {
[summaryWindow release];
} // end if
summaryWindow = [[SummaryWindowController alloc] initWithWindowNibName:@"SummaryWindow" owner:globalStatusController];
[summaryWindow showWindow:self];
[summaryWindow setGlobalStatusArray:globalStatusArray];
そして、nibがロードされたときに作成されたもので、同一ですが異なるオブジェクトですが、重複したNSLogが表示されなくなったため、現在はそうではないと思います。したがって、NSMutableArrayの基本的なメモリの問題だと思いますか?