问题描述
|
我的应用程序使用UINavigation控制器,最后通过向用户显示数字数据结束。
问题在于,仅当用户直接前进到计算屏幕而不点击返回按钮时,计算才是正确的。如果在任何时候按下后退按钮,即使在执行计算后,某些值也会被破坏。
例如,具有正确值的第一次运行:
2011-06-17 23:52:16.644 BlahBlah [19690:207] A = 146.000000 and B = 6.000000
如果在程序执行过程中的任何时候都按下了后退按钮,则结果为:
2011-06-17 23:54:05.888 BlahBlah [19690:207] A = 146.000000 and B = 4.012038
这些值即使在随后的重新计算中也将保持损坏,并且只有在程序完全重新启动后才会消失(即,我必须点击build并在Xcode中再次运行)。
我通常用脚本语言编写,因此由于缺乏对Obj C的经验,因此我认为这是内存管理问题。但是,我仔细研究了代码,确保每个alloc / new都有一个发行版,等等。我已经运行了调试器,该调试器没有什么可告诉我这部分代码。我现在完全陷入困境。
我的问题-我在做什么错,如何解决这个问题?
任何帮助表示赞赏。
进一步的信息-这就是我传递变量的方式。 myProfile是具有属性A和B(均为双精度)的对象的实例。
CalculateView *CalculateView = [[CalculateView alloc] initWithNibName:@\"Calculate\" bundle:nil];
CalculateView.myProfile = myProfile;
[self.navigationController pushViewController:CalculateView animated:YES];
我还应该提到A和B的值是从plist加载的。
解决方法
应该是这样
CalculateView *CalculateView = [[CalculateView alloc] initWithNibName:@\"Calculate\" bundle:nil];
CalculateView.myProfile = myProfile;
//wrong code -- Where is Create1?
[self.navigationController pushViewController:Create1 animated:YES];
//right code
[self.navigationController pushViewController:CalculateView animated:YES];