好吧,所以我对 NSMutableArray 类有点陌生,我想我遗漏了一些明显的东西。我有一个对象将 NSMutable 数组传递给我的窗口控制器,就像在 my.m 中一样:
summaryWindow = [[SummaryWindowController alloc] init];
[summaryWindow setGlobalStatusArray:globalStatusArray];
我在 summaryWindow 对象中有接收器方法,如下所示:
-(void)setGlobalStatusArray:(NSMutableArray *)myArray
{
if ([myArray count] >0) {
if (globalStatusArray) {
[globalStatusArray release];
}
globalStatusArray = [[NSMutableArray alloc] initWithArray:myArray];
NSLog(@"Summary Window Init with new array: %@",globalStatusArray);
我看到 NSLog 没问题,在同一个对象(summaryWindow)中我有以下方法:
- (NSMutableArray *)getGlobalStatusArray
{
return globalStatusArray;
}
现在我在我的 .h 文件中声明了 globalStatusArray
NSMutableArray *globalStatusArray;
所以不应该保留这个,因为我正在使用:initWithArray?
当我尝试在另一个 IBAction 方法中访问此值时:
- (IBAction)refreshButtonClicked:(id)sender
{
NSLog(@"The user has clicked the update button");
[ aBuffer addObjectsFromArray: globalStatusArray];
NSLog(@"Buffer is currently:%@",aBuffer);
[tableView reloadData];
}
NSMutable 数组为空
2011-08-18 10:40:35.599 App Name[65677:1307] The user has clicked the update button
2011-08-18 10:40:35.600 App Name[65677:1307] Buffer is currently:(
)
我尝试使用自己的方法来获取值,即 [self getGlobalStatusArray] 到,但我错过了一些巨大的东西。仅供参考 aBuffer 也在我的 .h 中声明,