0

我的程序可视化并绘制模拟神经元的电流以及它们如何相互作用。当我们尝试添加两个以上的神经元以进行 2/3 次可视化时,程序崩溃并在行上出现 EXC_BAD_INSTRUCTION 错误,该错误应该显示一个可以设置单个神经元参数的窗口。

我曾尝试打开 Zombie Objects 以获取更多信息,但随后程序不再崩溃,因此我无法获得更多信息。这个问题显然是一个僵尸对象问题,我只是不知道如何解决它。

- (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;
}

再次感谢

4

1 回答 1

0

如果有人发现这一点,我知道这非常无用,但我只是废弃了整个参数设置器窗口并重新构建它,仔细检查每个步骤中的错误和添加的功能。

于 2019-08-20T14:45:28.980 回答