iOS 4 无法访问变量导致应用程序崩溃

发布于 2024-09-07 06:02:27 字数 1850 浏览 8 评论 0原文

在 iOS 4 下,当我的应用程序从 xcode 安装时,它会在第一次启动时崩溃,但在后续启动时不会崩溃。

注释掉一些 addSubView 方法后,调试器终于给了我一条信息,

它在 [super viewDidLoad] 上崩溃。调试器指出:

无法访问变量“button1”

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor blackColor];

    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];

从控制台访问变量“button1”断点信息:

Pending breakpoint 1 - ""RootViewController.m":20" resolved
Pending breakpoint 2 - ""RootViewController.m":127" resolved
Pending breakpoint 3 - ""RootViewController.m":134" resolved
Pending breakpoint 4 - ""RootViewController.m":140" resolved
Pending breakpoint 5 - ""RootViewController.m":146" resolved
Pending breakpoint 6 - ""RootViewController.m":162" resolved
Pending breakpoint 7 - ""RootViewController.m":157" resolved
Pending breakpoint 8 - ""RootViewController.m":152" resolved
Pending breakpoint 9 - ""RootViewController.m":23" resolved
Pending breakpoint 10 - ""RootViewController.m":26" resolved
Pending breakpoint 11 - ""RootViewController.m":28" resolved
Pending breakpoint 12 - ""RootViewController.m":27" resolved
Pending breakpoint 13 - ""RootViewController.m":29" resolved
Pending breakpoint 14 - ""RootViewController.m":31" resolved
Pending breakpoint 15 - ""RootViewController.m":30" resolved
Pending breakpoint 16 - ""RootViewController.m":32" resolved
Pending breakpoint 17 - ""RootViewController.m":33" resolved
Pending breakpoint 18 - ""RootViewController.m":34" resolved
Pending breakpoint 19 - ""RootViewController.m":35" resolved
Pending breakpoint 20 - ""RootViewController.m":36" resolved
Pending breakpoint 21 - ""RootViewController.m":37" resolved
Pending breakpoint 22 - ""RootViewController.m":21" resolved
Pending breakpoint 23 - "objc_exception_throw" resolved

Under iOS 4, when my app installs from xcode it crashes on the first launch but not on subsiquent launches.

After commenting out some addSubView methods the debugger is finally giving me one piece of info

It crashes on [super viewDidLoad]. The debugger states:

Unable to access variable "button1"

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor blackColor];

    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];

Breakpoint info from the console:

Pending breakpoint 1 - ""RootViewController.m":20" resolved
Pending breakpoint 2 - ""RootViewController.m":127" resolved
Pending breakpoint 3 - ""RootViewController.m":134" resolved
Pending breakpoint 4 - ""RootViewController.m":140" resolved
Pending breakpoint 5 - ""RootViewController.m":146" resolved
Pending breakpoint 6 - ""RootViewController.m":162" resolved
Pending breakpoint 7 - ""RootViewController.m":157" resolved
Pending breakpoint 8 - ""RootViewController.m":152" resolved
Pending breakpoint 9 - ""RootViewController.m":23" resolved
Pending breakpoint 10 - ""RootViewController.m":26" resolved
Pending breakpoint 11 - ""RootViewController.m":28" resolved
Pending breakpoint 12 - ""RootViewController.m":27" resolved
Pending breakpoint 13 - ""RootViewController.m":29" resolved
Pending breakpoint 14 - ""RootViewController.m":31" resolved
Pending breakpoint 15 - ""RootViewController.m":30" resolved
Pending breakpoint 16 - ""RootViewController.m":32" resolved
Pending breakpoint 17 - ""RootViewController.m":33" resolved
Pending breakpoint 18 - ""RootViewController.m":34" resolved
Pending breakpoint 19 - ""RootViewController.m":35" resolved
Pending breakpoint 20 - ""RootViewController.m":36" resolved
Pending breakpoint 21 - ""RootViewController.m":37" resolved
Pending breakpoint 22 - ""RootViewController.m":21" resolved
Pending breakpoint 23 - "objc_exception_throw" resolved

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

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

发布评论

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

评论(1

那小子欠揍 2024-09-14 06:02:27

当尝试在调试模式下检查变量时,我遇到了相同的错误消息“无法访问变量”。

正如其中一条评论中提到的,我的问题是我正在调试我的发布版本而不是调试版本。

I had the same error message 'Unable to access variable' when trying to inspect a variable in debug mode.

As mentioned in one of the comments, my issue was that I was debugging my release build rather than the debug build.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文