<legend id='qSIXC'><style id='qSIXC'><dir id='qSIXC'><q id='qSIXC'></q></dir></style></legend>
        <i id='qSIXC'><tr id='qSIXC'><dt id='qSIXC'><q id='qSIXC'><span id='qSIXC'><b id='qSIXC'><form id='qSIXC'><ins id='qSIXC'></ins><ul id='qSIXC'></ul><sub id='qSIXC'></sub></form><legend id='qSIXC'></legend><bdo id='qSIXC'><pre id='qSIXC'><center id='qSIXC'></center></pre></bdo></b><th id='qSIXC'></th></span></q></dt></tr></i><div id='qSIXC'><tfoot id='qSIXC'></tfoot><dl id='qSIXC'><fieldset id='qSIXC'></fieldset></dl></div>
      1. <small id='qSIXC'></small><noframes id='qSIXC'>

          <bdo id='qSIXC'></bdo><ul id='qSIXC'></ul>
      2. <tfoot id='qSIXC'></tfoot>

        NSString 到 NSurl

        时间:2023-10-23

          • <tfoot id='7puO7'></tfoot>

              <legend id='7puO7'><style id='7puO7'><dir id='7puO7'><q id='7puO7'></q></dir></style></legend>

                <i id='7puO7'><tr id='7puO7'><dt id='7puO7'><q id='7puO7'><span id='7puO7'><b id='7puO7'><form id='7puO7'><ins id='7puO7'></ins><ul id='7puO7'></ul><sub id='7puO7'></sub></form><legend id='7puO7'></legend><bdo id='7puO7'><pre id='7puO7'><center id='7puO7'></center></pre></bdo></b><th id='7puO7'></th></span></q></dt></tr></i><div id='7puO7'><tfoot id='7puO7'></tfoot><dl id='7puO7'><fieldset id='7puO7'></fieldset></dl></div>

                <small id='7puO7'></small><noframes id='7puO7'>

                  <tbody id='7puO7'></tbody>
                  <bdo id='7puO7'></bdo><ul id='7puO7'></ul>
                • 本文介绍了NSString 到 NSurl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  无法让 NSSTRING 转换为 NSURL,item.image 保存了我通过 xml 获取的图像的 url

                  having trouble getting NSSTRING to convert to NSURL, item.image, holds the url for an image that im getting through xml

                  NSString *urlString = [NSString stringWithFormat:@"%@", item.image];
                  NSURL *url = [NSURL URLWithString:urlString];
                  
                  NSLog(@"string> %@ ", urlString);
                  NSLog(@"url> %@ ", url);
                  
                  2011-06-23 11:18:49.610 Test[10126:207] string> http://www.harlemfur.com/images/Dog_Olive.jpg       
                  2011-06-23 11:18:49.611 Test[10126:207] url> (null) 
                  

                  如果我尝试:

                  NSString *urlString = [NSString stringWithFormat:@"%@", item.image];
                  NSURL *url = [NSURL fileURLWithPath :urlString];
                  
                  2011-06-23 11:22:08.063 Test[10199:207] string> http://www.harlemfur.com/images/Dog_Olive.jpg
                  
                  2011-06-23 11:22:08.064 Test[10199:207] url> %0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20http://www.harlemfur.com/images/Dog_Olive.jpg%0A%20%20%20%20%20%20%20%20%20%20%20%20 -- / 
                  

                  推荐答案

                  NSString 制作 URL 时,别忘了先编码,试试这个:

                  When making URL from NSString, don't forget to encode it first, so try this:

                  NSString *urlString = [NSString stringWithFormat:@"%@", item.image];
                  NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];  
                  

                  对于 IOS ≥ 9.0 使用

                  NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
                  

                  这篇关于NSString 到 NSurl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使 iOS 块同步执行 下一篇:如何从资产网址保存视频

                  相关文章

                  <i id='AWAx5'><tr id='AWAx5'><dt id='AWAx5'><q id='AWAx5'><span id='AWAx5'><b id='AWAx5'><form id='AWAx5'><ins id='AWAx5'></ins><ul id='AWAx5'></ul><sub id='AWAx5'></sub></form><legend id='AWAx5'></legend><bdo id='AWAx5'><pre id='AWAx5'><center id='AWAx5'></center></pre></bdo></b><th id='AWAx5'></th></span></q></dt></tr></i><div id='AWAx5'><tfoot id='AWAx5'></tfoot><dl id='AWAx5'><fieldset id='AWAx5'></fieldset></dl></div>

                  1. <legend id='AWAx5'><style id='AWAx5'><dir id='AWAx5'><q id='AWAx5'></q></dir></style></legend>
                      <bdo id='AWAx5'></bdo><ul id='AWAx5'></ul>
                    <tfoot id='AWAx5'></tfoot>

                    <small id='AWAx5'></small><noframes id='AWAx5'>