gpt4 book ai didi

iphone - objective C SMS 选项会导致整个 App 崩溃?

转载 作者:行者123 更新时间:2023-11-28 23:11:08 25 4
gpt4 key购买 nike

我正在开发一个发送短信的 iPhone 应用程序,我正在使用 XCode 4.2

基本上我需要它来生成正文并向收件人添加电话号码。

我在 iPad 上运行该应用程序,它使应用程序崩溃,当我检查代码并发现接收者行出现问题时,当我删除该行时它工作得很好并且它指向消息应用程序。

知道如何避免这个问题吗?

这是我使用的代码

MFMessageComposeViewController *sms = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText]) {
sms.recipients=[NSArray arrayWithObjects:@"1111111111"];
sms.body= @"test";
sms.messageComposeDelegate = self;
[self presentModalViewController:sms animated:YES];
}

日志:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
sharedlibrary apply-load-rules all
target remote-mobile /tmp/.XcodeGDBRemote-692-73
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 7171 thread 0x1c03]
[Switching to process 7171 thread 0x1c03]
Re-enabling shared library breakpoint 1
Re-enabling shared library breakpoint 7
(gdb)

我收到以下绿色错误:

Tread1 : Program Received signal :"EXC_BAD_ACCESS"

和以下警告(黄色)

Missing sentinel dispatch

最佳答案

写这个作为答案,因为我没有发表评论的特权。
我认为问题在于

sms.receipients=[NSArrayWithObjects:@"1111111111"];

应该是

 sms.receipients=[NSArray arrayWithObjects:@"1111111111"];

编辑:

  sms.receipients=[NSArray arrayWithObjects:@"1111111111",nil]; 

  sms.receipients = [NSArray arrayWithObject:@"1111111111"];

关于iphone - objective C SMS 选项会导致整个 App 崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8234678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com