我在这里遇到了一个难题,将不胜感激,我的意思是任何帮助 =)
我是一名经验丰富的开发人员,因为我是 Objective-C/iPhone/Cocoa 的新手。
我想创建一个类控制器,我可以将 NSMutableArray 作为参数传递。
然后,我们有:
selTimeIntController = [[SingleSelectPickerViewController alloc] initWithSettings: listOfIntervals :kAlarmIntervalStr :myDataHolder.alarmInterval];
[self.navigationController pushViewController: selTimeIntController animated: YES];
[selTimeIntController release];
其中这个 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;
}
通过调试,我可以看到在我的 SingleSelectPickerViewController 上创建了我的 listOfIntervals。
这里我们有 SingleSelectPickerViewController' dealloc:
- (void)dealloc {
[super dealloc];
[listOfIntervals release];
[currentValue release];
[title release];
}
但是,每次我实例化我的 SingleSelectViewController 时,我都会立即收到一个带有以下堆栈的 EXEC_BAD_ADDRESS:
#0 0x96132688 in objc_msgSend ()
#1 0x00003ee2 in -[SingleSelectPickerViewController tableView:numberOfRowsInSection:] (self=0xd38940, _cmd=0x319a6bc0, tableView=0x102e000, section=0) at /Users/Cadu/iPhone/myApp/Classes/SingleSelectPickerViewController.m:115
#2 0x30a86bb4 in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] ()
#3 0x30a8879b in -[UITableViewRowData rectForFooterInSection:] ()
#4 0x30a883c7 in -[UITableViewRowData heightForTable] ()
#5 0x3094e8e6 in -[UITableView(_UITableViewPrivate) _updateContentSize] ()
#6 0x30940a7d in -[UITableView noteNumberOfRowsChanged] ()
#7 0x3094a2a0 in -[UITableView reloadData] ()
#8 0x30947661 in -[UITableView layoutSubviews] ()
#9 0x00b41d94 in -[CALayer layoutSublayers] ()
#10 0x00b41b55 in CALayerLayoutIfNeeded ()
#11 0x00b413ae in CA::Context::commit_transaction ()
#12 0x00b41022 in CA::Transaction::commit ()
#13 0x00b492e0 in CA::Transaction::observer_callback ()
#14 0x30245c32 in __CFRunLoopDoObservers ()
#15 0x3024503f in CFRunLoopRunSpecific ()
#16 0x30244628 in CFRunLoopRunInMode ()
#17 0x32044c31 in GSEventRunModal ()
#18 0x32044cf6 in GSEventRun ()
#19 0x309021ee in UIApplicationMain ()
#20 0x000020d8 in main (argc=1, argv=0xbffff0b8) at /Users/Cadu/iPhone/MyApp/
知道发生了什么吗?