【发布时间】:2023-03-31 18:30:02
【问题描述】:
我有一个 JSON 字符串,我知道问题出在哪里,但我不知道该怎么办。我在 JSON 字符串中查找了“禁止字符”,但它不起作用。 当您为 iPhone 的 FBStreamDialog 运行 show-method 时,一个视图会显示它最终发布到墙上时的样子。
当我的 JSON 字符串中的“description”属性被硬编码为@“Testing”时,就会发生这种情况。但是,一旦我添加了从数据源获取的文本,看起来像这样,它就不起作用了:
"description":"
LIVE: Uk's No:1 Reggae Singer Bitty Mclean + Joey Fever, Sthlms No:1 Reggae Voice.
DJs
Deejay Flash & Micke Goulos + Mc Fabulous G.
The Vinyl Bar
Up...
"
注意:我只显示 JSON 字符串的“描述”属性,因为问题出在哪里。
所以我尝试做的是,正如我之前解释过的,在“description”-属性中添加字符串“Testing”。这行得通。但我当然想拥有“描述”的数据源属性。所以我尝试用这段代码替换所有不是字母的字符:
shortString = [shortString stringByReplacingOccurrencesOfString:@"&" withString:@"och"];
shortString = [shortString stringByReplacingOccurrencesOfString:@"+" withString:@"plus"];
shortString = [shortString stringByReplacingOccurrencesOfString:@"," withString:@"komma"];
shortString = [shortString stringByReplacingOccurrencesOfString:@"'" withString:@"apostrof"];
shortString = [shortString stringByReplacingOccurrencesOfString:@":" withString:@"colon"];
输出是:
"description":"LIVEcolon Ukapostrofs Nocolon1 Reggae Singer Bitty Mclean plus Joey Feverkomma Sthlms Nocolon1 Reggae Voice.
DJs
Deejay Flash och Micke Goulos plus Mc Fabulous G.
The Vinyl Bar
Up...
哪个看起来像一个可批准的 JSON 字符串?
但显然不是,因为如果我使用数据源“描述”属性,facebook 视图永远不会显示它的外观。它只显示文本框“What's on your mind”。
这快把我逼疯了。
【问题讨论】:
-
我很绝望,这表明。刚刚尝试替换数字“1”......哦,我的上帝......;)
-
我可以补充一点,我根本没有收到错误消息。
标签: iphone cocoa-touch facebook