iPhone应用程序的浮点计算时释放到应用程序商店。 [英] iPhone App floating point calculations when released to the app store.
问题描述
我上周计算的 12V海洋和电瓶船使用发布了我的第一张个人iPhone应用程序。我曾大力测试了它在模拟器上和在我的iPhone,当我很舒服一切都很好,我归档的应用程序,并将其发布到苹果。当用户开始使用应用程序,他们注意到如预期计算不能正常工作。下面code,这是一个NSManagedObject模型的方法中,当在调试释放时被产生不同的输出。
I released my first solo iPhone app last week that calculates 12V Marine and Boat Battery usage. I had tested it vigorously on the simulator and on my iPhone, and when I was comfortable all was well, I archived the app and released it to Apple. When users started using the app, they noted a calculation was not working as expected. The below code, which is a method on a NSManagedObject model, was producing a DIFFERENT output when released to when in debug.
下面应该总结的总相关排放的项目 - 但如果没有BBDischarge的项目,那么它应该返回零。相反,当没有项目(因此循环不火),它返回一个数字,它是domesticAH(一个NSNumber)的直接产物。如果我设置domesticAH为100,下面dischargeAH返回8,如果设置domesticAH为1000,则返回83(显示时,浮动四舍五入)。我再次强调,在模拟器上运行,或者直接放到我的iPhone 4S时,下面的工作得很好,只有一次通过App Store发布了它搞砸了。
The below should sum up the total of the related Discharge items - but if there are no BBDischarge items, then it should return zero. Instead, when there are no items (thus the for loop doesn't fire) it returns a figure that is the direct product of the domesticAH (an NSNumber). If I set the domesticAH to 100, the below dischargeAH returns 8, if set the domesticAH to 1000, it returns 83 (the float is rounded when it is displayed). Again, I stress the below works fine when running on the simulator, or put directly onto my iPhone 4s, only once released through the app store does it screw up.
//Other dynamics hidden for simplicity
@dynamic domesticAH;
@dynamic voltage;
@dynamic profileDischarge;
-(NSNumber*) dischargeAmpH
{
float totalWattsPD;
//Calculate the watts per day so we can accurately calculate the percentage of each item line
for(BBDischarge* currentDischarge in self.profileDischarge)
{
float totalWatt = [currentDischarge.wattage floatValue] ;
float totalMinsPD = [currentDischarge.minutesPD floatValue]/60;
float totaltimesUsed = [currentDischarge.timesUsed floatValue];
float numberInOperation = [currentDischarge.number floatValue];
totalWattsPD = totalWattsPD + ((totalWatt * totalMinsPD) * (totaltimesUsed * numberInOperation));
}
int voltage = ([self.voltage integerValue] + 1) * 12;
float totalAmpsPD = totalWattsPD / voltage;
return [NSNumber numberWithFloat:totalAmpsPD];
}
正如你所看到的,self.domesticAH没有在功能的方法在任何地方,并且我不能重新创建此在模拟器中,我有一个很难跟踪下来。
As you can see, self.domesticAH is not featured in the method anywhere, and as I can't recreate this in the simulator, I am having a hard time tracking this down.
几个问题:
- 我可以调试我的应用程序的真人版?安装X code到我跑步,App Store的下载我的应用程序的实例吗?
- 有没有一种方法,我可以模拟从存档的安装 - 有人会建议特设分布做到这一点?我还没有使用特设呢。
- 任何其他想法,为什么这可能以这种方式行事?
推荐答案
更是一个比提示答案..但是,正如我在评论中已经说过:你可以查看发布和调试版本之间的不同的行为。
Is more a hint than an answer.. but, as I already said in comments: you can check the different behavior between Release and Debug version.
这不同的行为已经看到在过去。由Optmization级别设置给出。调试版本设置为无[-O0],而Release版本设置为最快,最小[-Os]。
This different "behavior" has been seen in the past. Is given by "Optmization Level" setting. Debug version is set to None [-O0], while the Release version is set to Fastest, Smallest [-Os].
An example here .. here another ..
这篇关于iPhone应用程序的浮点计算时释放到应用程序商店。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!