黑暗中的一枪-应用程序错误 [英] A shot in the dark - Application bug

查看:72
本文介绍了黑暗中的一枪-应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,如果您看不到我的应用程序,这将是黑暗中的一枪!

Ok so this is gonna be a bit of a shot in the dark without you being able to see my application!

我有一个错误.我有一个SwimmingPool类,我的应用程序将池从一个表视图传递到一个详细视图,您可以在其中查看所有SwimmingPool类字段.然后,您可以单击各个详细信息,对其进行编辑,然后保存.复制原始"池功能,并将其传递给负责实际进行更改的视图控制器.如果用户按保存,则将字段从副本复制到原始"

I have a bug. I have a SwimmingPool class, my app passes the pool from a tableview into a detail view where you can see all the swimmingPool class fields. You can then click on the individual detail, edit it, and then save it. The 'original' pool facility is copied and passed to the view controller responsible for actually making changes. If the user presses save, the fields are copied from the copy into 'original'

switch (self.sectionFromParentTable) {
    case KNameIndex:
        self.thePoolFacility.name = self.thePoolFacilityCopy.name;
        self.thePoolFacility.type = self.thePoolFacilityCopy.type;
        break;

    case KAddressIndex:
        self.thePoolFacility.address = self.thePoolFacilityCopy.address;
        break;

    case KPhoneNumberIndex:
        self.thePoolFacility.phoneNumber = self.thePoolFacilityCopy.phoneNumber;
        break;

    case KWebAddressIndex:
        self.thePoolFacility.webAddress = self.thePoolFacilityCopy.webAddress;          
        break;
    case KPricesIndex:
        self.thePoolFacility.prices = self.thePoolFacilityCopy.prices;
        break;
    case KPoolIndex:
        self.thePoolFacility.pools = self.thePoolFacilityCopy.pools;
    default:
        break;
}

[self.navigationController popViewControllerAnimated:YES];

我能猜出一个执行以下操作的错误吗?

Can I have some guesses at a bug that does the following:

  1. 该错误导致更改完成 到一个班级"字段中未保存的字段.特别是一个名为TimeEntry的类,它在一个名为TermTimes的Dictionary中,在一个名为TermTimes的词典中,在一个可变数组中,在一个称为pool的类中,然后在一个称为Pools的可变数组中.

  1. The bug results in the changes done to a class' fields not being saved. In particular a class called TimeEntry, in a mutable array called Monday in a Dictionary called TermTimes in a class called pool and then in a mutable array called Pools.

它似乎是随机的.有时候 完美地工作.有时候 不!我无法重现错误, 只有当我幸运的时候我才能得到它 保存.我的预感是 对时间敏感的.例如,如果我是 输入池时间表 开放时间,如果我快速添加一个 很少输入并通常保存 工作正常.如果我填写一个整体 时间表,那么它比没有更多 不保存.

It's appears random. Sometimes it works perfectly. Sometimes it doesn't! I can't recreate the error, only if I'm lucky can i get it not to save. My hunch is it could be time sensitive. For example, If I am entering a timetable for Pool opening times, if i quickly add a few entries and save it usually works fine. If I fill in a whole timetable then it more than not doesn't save.

激怒尝试并调试似乎随机发生的错误.关于这种史诗般的错误搜寻有什么暗示吗?

It's infuriating the try and debug an error that seems to happen at random. Any hints on such an epic bug hunt?

推荐答案

解决此类问题(似乎无法可靠地重现)的最佳方法之一是在您期望的各个区域插入日志记录代码某些事情正在发生.记录可能发生错误的位置,记录您期望的值以及所拥有的值,等等.接下来,尝试,尝试,尝试直到可以重现该错误为止.

One of the best ways to tackle this type of problem (where it seemingly can't be reproduced reliably) is to insert logging code in various areas where you expect certain things to be happening. Log places that errors could occur, log what values you are expecting and what you have, etc. Next, try, try, try until you can reproduce the bug.

与以前不同,现在您可以查看日志,看看问题出在哪里.如果到处看起来仍然正确,请在其他位置插入更多日志记录代码.如果您发现有问题,但不了解,请在该区域添加更多日志记录代码,并缩小问题范围.

Unlike before, you now have a log to look at and see where things went wrong. If things still look correct everywhere, insert some more logging code elsewhere. If you see something go wrong, but don't understand it, put more logging code in that area and keep narrowing the problem down.

希望这将导致有关错误发生方式的新假设,并且您将能够在调试器下可靠地重现它并对其进行修复!

Hopefully this will lead to new hypotheses about how the bug happens, and you will be able to reproduce it under the debugger reliably and fix it!

如duffymo所述,多线程可能是罪魁祸首,如果您有意使用多个线程,那么多线程将是首先进行调查的好地方.

As duffymo mentioned, multithreading could be the culprit, and would be a good place to investigate first if you're knowingly using multiple threads.

这篇关于黑暗中的一枪-应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆