Trouble with newline character while programming for the iPhone

╄→гoц情女王★ 提交于 2019-12-13 06:38:04

问题


I'm storing text in a sqlite file and setting the text of a UITextView to be the value of that text. The only problem is that the UITextView isn't honoring the newline character. Instead, it's printing it out as text. Here's an example:

Stored in fruit.sqlite and passed to theFruit object:
requiredFruit = "apples\n oranges\n pears"

NSString *theFruit = [NSString stringWithFormat:@"%@", theFruit.requiredFruit];
generalOutlet.text = theFruit;

It Displays apples\n oranges\n pears but I want it to display

  • apples
  • oranges
  • pears

回答1:


Preventing sqlite from escaping backslash

sqlite files are WYSIWYG format apparently. I used a text editor to write an sql update statement and just used the return key when typing out the list. I then read that file from terminal and it seems to have worked out.



来源:https://stackoverflow.com/questions/3384811/trouble-with-newline-character-while-programming-for-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!