NSMutableArray来自json的数组(NSMutableArray to array from json)
我需要将NSMutableArray从JSON转换为NSArray。 我加载了JSON并将其放在NSMutableArray中。
NSMutableArray *banner = [[NSMutableArray alloc] init]; banner = [responseObject objectForKey:@"banner"];
这是测试循环:
for(int i = 0; i < [slider count]; i++) { NSLog(@"%@", [[banner objectAtIndex:i] objectForKey:@"resim"]); }
这是来自JSON的日志:
( { id = 1; resim = "http://localhost/sample_Files/banner_api/1.jpg"; }, { id = 2; resim = "http://localhost/sample_Files/banner_api/2.jpg"; }, { id = 3; resim = "http://localhost/sample_Files/banner_api/3.jpg"; } )
我想将所有这些设置为下面的NSArray:
NSArray *allImages = @[@"http://localhost/sample_Files/banner_api/1.jpg",@"http://localhost/sample_Files/banner_api/2.jpg",@"http://localhost/sample_Files/banner_api/3.jpg"];
我怎样才能做到这一点?
I need to convert an NSMutableArray to an NSArray from JSON. I loaded the JSON and put it in an NSMutableArray.
NSMutableArray *banner = [[NSMutableArray alloc] init]; banner = [responseObject objectForKey:@"banner"];
This is test for loop:
for(int i = 0; i < [slider count]; i++) { NSLog(@"%@", [[banner objectAtIndex:i] objectForKey:@"resim"]); }
This is log from the JSON:
( { id = 1; resim = "http://localhost/sample_Files/banner_api/1.jpg"; }, { id = 2; resim = "http://localhost/sample_Files/banner_api/2.jpg"; }, { id = 3; resim = "http://localhost/sample_Files/banner_api/3.jpg"; } )
I want to set all of this to be like the below NSArray:
NSArray *allImages = @[@"http://localhost/sample_Files/banner_api/1.jpg",@"http://localhost/sample_Files/banner_api/2.jpg",@"http://localhost/sample_Files/banner_api/3.jpg"];
How can I do this?
原文:https://stackoverflow.com/questions/33816679
更新时间:2022-06-03 19:06
最满意答案
你在扩展PDO吗? 当我想实现一个PDO对象时,我写这个:
$pdoObj = new PDO( 'mysql:dbname=' . DB_NAME . ';host=' . HOST_NAME . ";", USER, PWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );
Are you extending PDO? When i want to instanciate a PDO object i write this:
$pdoObj = new PDO( 'mysql:dbname=' . DB_NAME . ';host=' . HOST_NAME . ";", USER, PWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );
相关问答
更多-
打印时设置PDF的名称(Setting Name of PDF When Printing)[2022-05-25]
在提出一个更普遍的问题之后 ,这似乎是不可能的。 我很确定直接在浏览器中打开的文件的标题行为。 如果您尝试使用上述标题保存文件,则将正确填充文件名。 After asking a more generalized question, it would seem it's impossible. I'm fairly certain the title behavior for files opened directly in the browser. If you attempt to save the f ... -
当我看着你的代码时,我看到很多奇怪的事情。 你说你需要UTF-8,但是你使用BaseFont.CP1252而不是BaseFont.IDENTITY_H (这是你使用Unicode时需要的“编码”)创建一个BaseFont对象。 您使用标准的Type 1字体Courier,这是一种不知道如何渲染é,è,à...以及从未嵌入的字体的字体。 如文档所述,在这种情况下, BaseFont.EMBEDDED参数将被忽略! 您不要将此字体与具有实际内容的对象一起使用。 将实际内容放入使用默认字体“Helvetica”创 ...
-
元命令是错误的。 它应该是 要么 (没有http-equiv)。 但请注意,对字符集使用元命令并不能保证所需的字符集确实被使用。 实际的http头可以用它自己的字符集覆盖这个设置。 此外,关于您的评论,它的正确渲染,请注意,Web浏览器可能会使用不同的算法来确定编码比DLL。 修正元命令可能有帮助,也可能没有帮助。 Th ...
-
PDF编码问题(PDF encoding issue)[2022-10-11]
抱歉,上面的链接失败了。 最后,我们发现将PDF作为包装在JSON中的二进制数据发送不起作用。 该服务的创建者发现他们的框架正在轻微地操纵二进制数据并转换一些字符。 他们最终切换到Base 64编码,效果很好。 Sorry the above link failed. In the end we found that sending the PDF as binary data wrapped in JSON did not work very well. The creators of the servi ... -
原来FontDescriptor字典中的Flags很重要。 对于Times,需要设置非符号标志(第6位)。 Times实际上是使用TrueType字体排版的事实与它无关。 要使用字体的内置编码,不应设置Type1 Font字典的Encoding条目。 如果它包含非空的Differences数组,或者Adobe Reader将出错,则只能添加Encoding字典(省略BaseEncoding )。 通过这些预防措施,生成的PDF可在上面列出的所有9个查看器应用程序中正确显示 Turns out the Fla ...
-
5 0 obj<> [...] BT /F1 24 Tf 100 100 Td (ąčęėį šąčįžė)Tj ET 如何更改此文档以使字符正确显示? 除了/编码带有/差异的字典之外,最有可能是将@Xinwang设置为编码的最简单的方法,我想指出你可能还有一些额外的问题:并非所有字符都有一个关联的字形/ Helvetica或任何其他核心标准14字体! 参看 规范ISO 32000-1 ; 第9.6.2.2 ...
-
为了回答我自己的问题,我转到了Perl PDF :: Extract,它正在运行。 to answer my own question, I moved to Perl PDF::Extract and it's working.
-
你在扩展PDO吗? 当我想实现一个PDO对象时,我写这个: $pdoObj = new PDO( 'mysql:dbname=' . DB_NAME . ';host=' . HOST_NAME . ";", USER, PWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") ); Are you exte ...
-
PDFJS和PDF编码(PDFJS and PDF encoding)[2022-12-15]
我不认为你的字符串转换例程rawStringToBuffer()做你想要的。 您正在将文件作为文本读取,将UTF-8转换为UTF-16。 但是rawStringToBuffer()只取每个UTF-16字符的低位字节并丢弃高位字节,这不是逆变换。 这适用于7位ASCII数据,但不适用于其他字符。 将字符串转换为UTF-8的最佳方法是使用TextEncoder API (并非所有浏览器都支持,但可以使用polyfill)。 但是,不需要将数据从UTF-8转换回来。 只需使用FileReader.readAsAr ... -
此插件使用jsPDF作为PDF生产者。 这是该插件的一个已知问题,它没有真正的unicode支持。 只支持几个unicode字符(如德语变音符号)。 This plugin uses jsPDF as PDF producer. It is a known issue of that plugin, that it has no real unicode support. Only a few unicode characters (as german umlauts) are supported.