简体   繁体   English

尽管已启用ARC,但应用程序崩溃

[英]App Crashing Despite of Being ARC Enabled

I have been working on an iOS App for sometime now and its almost ready to submit. 我一段时间以来一直在开发iOS应用,并且几乎可以提交了。 However, when I gave it to few people for testing purposes (running iOS 5)..they reported cases where the app crashes and the home screen is displayed on the phone OR a frozen app screen appears with no response whatsoever 但是,当我将它提供给少数人进行测试(运行iOS 5)时,他们报告了应用程序崩溃且手机上显示主屏幕或冻结的应用程序屏幕而无任何响应的情况

The app is ARC enabled and Xcode shows no warnings. 该应用程序已启用ARC,并且Xcode不显示任何警告。 So, I'm relli tensed about what's going wrong. 所以,我对发生的问题感到紧张。 I have declared properties in the following fashion: 我以以下方式声明了属性:

@property (nonatomic) IBOutlet UILabel *devCountLabel;

@property (nonatomic) IBOutlet UIView *splashView;

Likewise other properties are declared. 同样,声明其他属性。 Could anyone provide a solution? 谁能提供解决方案? It is mainly a network based app and thus, CoreData usage is minimum. 它主要是基于网络的应用程序,因此CoreData的使用量最少。

PS: The App doesn't crash in the simulator, so I'm guessing it has something related to memory. PS:该应用程序不会在模拟器中崩溃,因此我猜它与内存有关。 And the crashes are random. 崩溃是随机的。 So, repeating a set of steps to reproduce the crash doesn't help either. 因此,重复执行一组步骤来重现崩溃也没有帮助。 For Eg. 例如 When I click a button, modalViewControllerAnimation results in normal case. 当我单击一个按钮时,在正常情况下会出现modalViewControllerAnimation。 Now this occurs as expected most of the time and freezes the app other times. 现在,这种情况在大多数情况下都按预期发生,而在其他时间冻结了该应用程序。

The crash logs will help, but here is my guess: 崩溃日志将有所帮助,但这是我的猜测:

Interface Builder Outlet properties should be weak , so they become nil after they get released. Interface Builder Outlet属性应该是weak ,因此它们在释放后变为nil

In your code their semantics is assign (it's by default, since you wrote nonatomic only), which is used for primitive types. 在您的代码中,它们的语义是assign (默认情况下,因为您只写了nonatomic ,所以是语义的),该语义用于原始类型。 And when it gets released, you get a dangling pointer, and when you use it, the app crashes. 当它发布时,您会得到一个悬空的指针,并且当您使用它时,该应用程序将崩溃。

Try this: 尝试这个:

@property (weak, nonatomic) IBOutlet UILabel *devCountLabel;
@property (weak, nonatomic) IBOutlet UIView *splashView;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM