0

我是名为 CountdownCenter 的 cydia 调整的开发人员。我试图为我的小部件创建一个数字时钟外观,所以我创建了一个示例应用程序,可以完美地做到这一点。完成此操作后,我将此数据传输到我的调整代码中,但这会导致我的 iPhone 上的 SIGSEGV 崩溃。经过一些测试,我找到了导致崩溃的部分,但我只是找不到问题所在,因为这部分可以在普通应用程序上运行。你能帮我吗?

这是代码:

int digitarray[10];
    int c = 0;
    digitarray[0] = 0;
    digitarray[1] = 0;
    while (secon>0) {
        int digitt = secon % 10;
        digitarray[c] = digitt;
        secon /= 10;
        c++;
    }
        lbl.text = [NSString stringWithFormat:@"%d", digitarray[0]];
          [self selectimage:digitarray[0] img:numview10];
4

1 回答 1

0

SIGSEGV usually means, that you're trying to access memory, that you are not allowed to access. (btw are you testing this with a release build?) Maybe f.e. here (there are some other similar places too):

c = 0;
while (secon>0) {
    int digitt = secon % 10;
    digitarray[c] = digitt;
    secon /= 10;
    c++;
}

There are some possibilities:

  • secon (horrible variable names btw...) is a float or double, in that case the while loop is either never entered or never left
  • c becomes so large that it's beyond digitarray's bounds

To solve this issue I would recommend to but a breakpoint at the beginning of your code and check it step by step.

于 2013-04-16T20:17:49.443 回答