什么是使iOS应用程序崩溃的可靠方法? [英] What's a reliable way to make an iOS app crash?

查看:136
本文介绍了什么是使iOS应用程序崩溃的可靠方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试我的应用程序在现场的崩溃报告,当用户执行一个真实用户不太可能意外执行的特定操作时故意让它崩溃。



<但是,在编译时不会产生警告的应用程序崩溃的可靠方法是什么?



编辑:请注意这个问题的许多看似明显的答案导致Cocoa捕获的异常,因此不会导致应用程序崩溃。

解决方案

在Objective-C中直接使用C导致访问不良

  strcpy(0,bla); 

注意:虽然这适用于我所知道的任何系统 - 在未来版本的C运行时或编译器,这可能不会导致崩溃。请参阅 Objective-C中的空指针取消引用未定义行为吗?



(在swift中,您必须桥接到objC才能执行此操作)


I want to test my app's crash reporting out in the field by deliberately having it crash when the user performs a particular action that a real user is unlikely to do accidentally.

But what's a good reliable way of making the app crash that doesn't create a warning at compile time?

Edit: Note that many seemingly obvious answers to this question result in exceptions that get caught by Cocoa and thus don't result in the app crashing.

解决方案

in Objective-C use C directly to cause a bad access

strcpy(0, "bla");

Note: while this works on any system I know -- in a future version of the C runtime OR the compiler this might not lead to a crash anymore. see Is null pointer dereference undefined behavior in Objective-C?)

(in swift you would have to bridge to objC to do this)

这篇关于什么是使iOS应用程序崩溃的可靠方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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