What's a reliable way to make an iOS app crash?

后端 未结 18 1763
無奈伤痛
無奈伤痛 2020-12-12 11:47

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 accid

18条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 12:19

    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)

提交回复
热议问题