gpt4 book ai didi

ios - NSXMLParser 不解析百分号

转载 作者:行者123 更新时间:2023-11-28 22:22:16 27 4
gpt4 key购买 nike

我在 XML 中有一行包含 % 符号。但是 NSXMLParser 也改变了一些数字,如下所示

2013-11-16 01:08:07.102 ECP[46386:a0b] string is Increased Discount to 45% from Sun City Tours
2013-11-16 01:08:07.102 ECP[46386:a0b] Deals CURRENT IS Increased Discount to 45 0.000000rom Sun City Tours

我在 FoundCharacter 方法中的代码是,

  NSLog(@"string is %@", string);

if([string length]>0)
[currentStringValue appendFormat:string];

NSLog(@"Deals CURRENT IS %@", currentStringValue);

最佳答案

使用appendString:,而不是appendFormat:

appendFormat: 将字符串中的 "% f" 视为格式规范,因此将其替换为 float 。 (并且由于没有相应的参数传递给 appendFormat:,你有未定义的行为,你的程序可能也会崩溃。)

关于ios - NSXMLParser 不解析百分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20009754/

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