我的程序可视化并绘制了模拟神经元的电流以及它们如何相互作用的图形。当我们尝试添加两个以上要被可视化的神经元的2/3倍时,程序崩溃,并在该行上显示EXC_BAD_INSTRUCTION错误,该错误应显示可以设置单个神经元参数的窗口。
我尝试打开“僵尸对象”以获取更多信息,但是该程序不再崩溃,因此我无法获取任何更多信息。这个问题显然是僵尸对象问题,我只是想不出解决方法。
- (IBAction) showParameterSetterWindow:(id)sender
{
if (parameterSetter == nil)
{
ParameterSetter *newParameterSetter = [[ParameterSetter alloc] initWithDefaultWindowNib];
[self setParameterSetter:newParameterSetter];
}
[[self parameterSetter].window orderFront:self]; //Error appears here
} // showSynapseWindow
每个位置的错误是:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
在调试窗口中将其打印出来:
019-08-05 15:15:04.306293-0400 RoboLobsterSimu[1680:175553] Parameter Setter AwakeFromNIB completed RoboLobsterSimu(1680,0x10013e5c0) malloc: Heap corruption detected, free list is damaged at 0x60001412b1f0 *** Incorrect guard value: 3 RoboLobsterSimu(1680,0x10013e5c0) malloc: *** set a breakpoint in malloc_error_break to debug RoboLobsterSimu(1680,0x10013e5c0) malloc: Heap corruption detected, free list is damaged at 0x600014128020 *** Incorrect guard value: 13830554455654793216 RoboLobsterSimu(1680,0x10013e5c0) malloc: *** set a breakpoint in malloc_error_break to debug warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
让我知道是否需要更多信息来解决问题,谢谢! 这是要求我添加的代码段。非常感谢你!
这是initWithDefaultWindowNib
- (id)initWithDefaultWindowNib
{
/* AnalysisWindowController *awc;
awc = [super initWithWindowNibName:@"AnalysisWindowController"];
if (!awc)
{
NSLog(@"Warning! Could not load AnalysisWindowController file.\n");
}
else
{
NSLog(@"AnalysisWindowController Nib Loaded");
[awc logAnalysisWindowController];
}
return awc;
*/
if (!self){
self = [super initWithWindowNibName:@"AnalysisWindowController"];
if (self)
{
[self logAnalysisWindowController];
}
else
{
NSLog(@"Warning! Could not load AnalysisWindowController nib.\n");
}
}
return self;
}
它在另一个文件中也这样调用:
- (id)initWithDefaultWindowNib
{
if (!self){
self = [super initWithWindowNibName:@"ParameterSetter"];
if (self)
{
NSLog(@"Executing InitWithDefaultWIndowNib in Parameter Setter");
}
else
{
NSLog(@"Warning! Could not load ParameterSetter nib.\n");
}
}
return self;
}
对于setParameterSetter,教授说:“这就是合成运算符的作用。它创建了一个setter和getter。setParameterSetter被创建为ParameterSetter的setter。ParameterSetter是该getter”。
无论哪种方式,这里都是parameterSetter:
@property (nonatomic, strong) ParameterSetter *parameterSetter;
- (ParameterSetter *)parameterSetter
{
if (parameterSetter == nil)
{
ParameterSetter *newParameterSetter = [[ParameterSetter alloc] initWithDefaultWindowNib];
[self setParameterSetter:newParameterSetter];
}
return parameterSetter;
}
再次感谢
答案 0 :(得分:0)
如果有人发现了这一点,我知道这是无济于事的,但是我只是废弃了整个参数设置器窗口,并对其进行了重建,请仔细检查每个步骤的错误以及所添加的功能。