将文本从文本框保存到 nsstring,然后再保存回文本框
我正在为 iPhone 创建一个聊天应用程序。电话之间的聊天工作正常,但我想保留聊天记录。所以我创建了一个 NSstring ,每次用户退出聊天进入主菜单时,文本框中的文本都会存储在 nsstring 中。当用户返回聊天时,我希望将字符串加载到文本框中。但当我尝试这个时,它不起作用,而是崩溃了。转录内容保存在 nsstring 中,但无法加载回文本框中。如果它有帮助,我得到的错误是:程序收到信号:“EXC_BAD_ACCESS”
任何帮助或其他保存记录的方法表示赞赏。
谢谢
i am creating a chat app for iphone. The chat between the phones work fine but i want to keep a transcript of the chat. So i created an NSstring and every time the user exits the chat to go to the main menu, the text from the text box is stored in the nsstring. When the the user goes back into the chat I want the string to be loaded into the text box. But when I tried this it does not work instead it crashes. The transcript is saved in the nsstring but cannot be loaded back into the text box. If it helps the error I get is: Program received signal: "EXC_BAD_ACCESS"
Any help or other way to save the transcript is appreciated.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像你的变量之一没有被正确保留,可能是 NSString。如果你这样做,
你将有一个指向文本框字符串的指针,但是一旦文本框被释放,该字符串就会被释放。如果你想抓住绳子,请使用
This looks like one of your variables is not being retained properly, possibly the NSString. If you do it like this
You'll have a pointer to the textBox's string, but the string will be released as soon as the textBox is dealloced. If you want to hang on to the string, use