我在这里遇到一个难题,不管感谢,我的意思是任何帮助=)
我是一名经验丰富的开发人员,我是Objective-C/iPhone/Cocoa的新手.
我想创建一个类控制器,我可以将NSMutableArray作为参数传递.
然后,我们有:
selTimeIntController = [[SingleSelectPickerViewController alloc] initWithSettings: listOfIntervals :kAlarmIntervalStr :myDataHolder.alarmInterval];
[self.navigationController pushViewController: selTimeIntController animated: YES];
[selTimeIntController release];
Run Code Online (Sandbox Code Playgroud)
这个listOfIntervals是一个已经是alloc/init的NSMutableArray*.
在我的SingleSelectPickerViewController上,我们有:
-(id)initWithSettings:(NSMutableArray*)sourceArray :(NSString*)viewCurrentValue :(NSString*)viewTitle {
if(self = [self initWithNibName: kNibName bundle: [NSBundle mainBundle]]) {
listOfIntervals = [NSMutableArray arrayWithArray: (NSMutableArray*)sourceArray];
currentValue = [[NSString alloc] initWithString: viewCurrentValue];
title = [[NSString alloc] initWithString: viewTitle];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
通过调试,我能够在SingleSelectPickerViewController上看到我的listOfIntervals.
这里我们有SingleSelectPickerViewController'dealloc:
- (void)dealloc {
[super dealloc];
[listOfIntervals release];
[currentValue release];
[title release];
}
Run Code Online (Sandbox Code Playgroud)
但是,每次我实例化我的SingleSelectViewController时,我都会收到一个带有以下堆栈的EXEC_BAD_ADDRESS:
#0 0x96132688 in objc_msgSend ()
#1 0x00003ee2 in -[SingleSelectPickerViewController tableView:numberOfRowsInSection:] …Run Code Online (Sandbox Code Playgroud)