在 Objective-C 中遇到的最常见/不常见的错误消息是什么以及导致这些错误的原因是什么?

发布于 2024-10-12 19:17:53 字数 76 浏览 4 评论 0原文

我一直在尝试维护一个我在开发过程中遇到的所有错误消息及其常见原因和修复的列表。您遇到的常见(和不常见)错误消息是什么?您是如何修复它们的?

I've been trying to maintain a list of all the error messages I ever encounter while developing and their common causes and fixes. What are the common (and the not so common) error messages you encountered and how did you fix them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃酥萝莉 2024-10-19 19:17:53

EXC_BAD_ACCESS 当引用指向已被 dealloc 处理的对象的指针时

EXC_BAD_ACCESS when referencing a pointer that points to an object that has been dealloc'ed

南烟 2024-10-19 19:17:53

一般来说,我发现 Objective-C 异常和错误消息是不言自明的。我认为,学习使用带有 Objective-C 异常断点的调试器来定位导致崩溃的特定行,比尝试编译解决常见错误的方法列表会更好。

也就是说,我认为经常引起混淆的一个不明显的错误是“无法识别的选择器 foo:发送到 BarClass”。虽然这是一个错误的原因应该很清楚,但回答这是如何发生的可能会更困难,而且我看到两个常见原因:

  1. 应用程序试图在超类的实例上调用子类的方法。通常是开发人员未能更改 IB 中对象类的结果。
  2. 对象在释放后被过度释放或以其他方式引用。如果某个其他类的新实例现在占用该内存地址,则应用程序会遇到“无法识别的选择器”异常,而不是“BAD_ACCESS”。

In general I find objective-c exception and error messages tO be self-explanatory. I think you would be better served by learning to use the debugger with breakpoints on objective-c exceptions to locate the specific line causing a crash than by trying to compile a list of recipies for resolving common errors.

That said the one non-obvious error I see as a frequent point of confusion is "unrecognized selector foo: sent to BarClass". While the reason why that is an error should be clear answering how that happened can be harder and I see two common causes:

  1. An app is attempting to call a subclass' method on an instance of a super class. Often a result of developers failing to change the class of objects in IB.
  2. An object has been over-released or otherwise referenced after being deallocated. If a new instance of some other class now occupies that memory address the app with hit an "unrecognized selector" exception rather than a "BAD_ACCESS".
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文