gpt4 book ai didi

objective-c - 重复的 NSLog 条目

转载 作者:行者123 更新时间:2023-12-03 16:33:16 26 4
gpt4 key购买 nike

我不知道是否可以在此处包含相关的代码,因为我的项目如此之大,但是是否有任何典型原因导致 NSLog 有时会重复一些警告并调用它哪里只发生一次调用/错误?

举个例子,我有一个 NSBox 的子类,它在 awakeFromNib 上初始化另一个类的实例:

- (void) awakeFromNib {
burbControllerInstance = [[BurbController alloc] init];
if (burbControllerInstance) {
NSLog(@"init ok");
}
}

我得到 NSLog 打印“init ok”两次。我不明白为什么这个子类会在我的项目中的任何地方被“唤醒”两次。这是一个更大问题的一部分,我无法让变量从我正在创建其实例的类中返回除 nil 之外的任何内容。我想知道 double 值是否与此有关。

最佳答案

This post可能会有所帮助,i。 e.一条评论:

Also important: awakeFromNib can be called multiple times on the controller if you use the same controller for several nibs – say, you’re using the app delegate as the owner of both the app’s About Box and preferences dialog. So you’ll need an extra guard test if you use awakeFromNib for anything but initializing the nib objects

更新:更有趣的可能是 this ,其中作者提到 awakeFromNib 被调用两次。不幸的是,这个特定问题没有真正的答案,但也许有一些基本的想法。

更新#2:来自 stackoverflow.com 的另一个潜在解决方案:View Controller calls awakeFromNib twice.

关于objective-c - 重复的 NSLog 条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5844214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com