Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 格式化设置包中的字符串_Objective C_Ios - Fatal编程技术网

Objective c 格式化设置包中的字符串

Objective c 格式化设置包中的字符串,objective-c,ios,Objective C,Ios,我在iPhone项目的设置包中有一个字符串 test string that formats something like this => string%@inside%dastring 使用一个字符串和一个整数,然后我使用这个字符串 NSString *result = [NSString stringWithFormat:stringFromBundle, replace_string, an_int_number]; 但是结果字符串没有格式化。 我必须将从捆绑包中获取的字符串转

我在iPhone项目的设置包中有一个字符串

test string that formats something like this => string%@inside%dastring 
使用一个字符串和一个整数,然后我使用这个字符串

NSString *result = [NSString stringWithFormat:stringFromBundle, replace_string, an_int_number];
但是结果字符串没有格式化。
我必须将从捆绑包中获取的字符串转换为其他编码吗?

当您记录stringFromBundle时,您得到了什么?我以从捆绑包中输入字符串的方式获取字符串,其中包含%@和%d。我不确定为什么字符串没有使用调用stringWithFormat进行格式化。在调用之后,我仍然会得到包含格式化指令的字符串。如何将该字符串放入包中,以及使用什么方法将其取出?另外,是否有什么原因需要将它放在bundle中而不是代码中?字符串非常大,因此我将它放在bundle中而不是代码中。我只是把数据和代码分开。我将字符串作为条目放入主捆绑包中,然后调用NSBundle类的“objectForInfoDictionaryKey”函数。我没有创建新的设置捆绑包,因为没有太多与代码相关的数据放在单独的捆绑包中。我将字符串string%@inside%dastring放在我的应用程序的info.plist文件中,并使用您提到的方法将其取出,它与stringWithFormat中的格式字符串一样工作正常:。所以,我不确定你的应用程序发生了什么。你的字符串在info.plist中吗?那么,您是如何从Xcode中输入它的,还是在Xcode之外编辑XML文件的?