尝试访问NSArray时出现问题

时间:2009-07-28 18:48:26

标签: iphone-sdk-3.0

我正在尝试在loadView方法中初始化NSArray。当我初始化它时,它在内存中有一定的地址。

然后当我触摸屏幕时,我调用了刷新方法。当我在这里调试混合数组时,它具有相同的地址,但内容是{(int)[$ VAR count]}对象......

这是我的代码:

@implementation MCPickerViewController
#pragma mark Overriden methods

- (void)loadView {
    [super loadView];

    blends = [NSArray arrayWithObjects:@"Piepje", @"Paapje", nil];

    pickerView = [[MCPickerView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    pickerView.delegate = self;
    [self setView:pickerView];
}

#pragma mark Delegate methods for MCPickerView

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [self refresh];
}

#pragma mark Personal methods

- (void)refresh {
    NSLog(@"count: %i", [blends count]);
}
@end

我希望有人可以帮助我,因为我被困了很长时间!

日Thnx !!

1 个答案:

答案 0 :(得分:1)

我不完全确定问题是什么,但你需要保留混合数组(并在某处释放它)。

我还建议您阅读Apple's memory management guide以了解何时应保留,释放,自动释放等。

相关问题