• <bdo id='dzPMJ'></bdo><ul id='dzPMJ'></ul>

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

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

      1. 获取 URL 字符串的域部分?

        时间:2023-10-03
          • <bdo id='nLDiS'></bdo><ul id='nLDiS'></ul>

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

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

                  <tbody id='nLDiS'></tbody>

                1. 本文介绍了获取 URL 字符串的域部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有 URL 的 NSString,这样:

                  I have an NSString with an URL, in this way:

                  http://someurl.com/something
                  

                  我怎样才能只获得 someurl.com?我已经尝试过 substringToIndex 没有运气:(

                  How would I get someurl.com only? I've already tried substringToIndex with no luck :(

                  提前致谢:)

                  推荐答案

                  Objective-C

                  NSString* urlString = @"http://someurl.com/something";
                  NSURL* url = [NSURL URLWithString:urlString];
                  NSString* domain = [url host];
                  

                  斯威夫特 2

                  var urlString = "http://someurl.com/something"
                  var url = NSURL(string: urlString)
                  var domain = url?.host
                  

                  Swift 3+

                  var urlString = "http://someurl.com/something"
                  var url = URL(string: urlString)
                  var domain = url?.host
                  

                  这篇关于获取 URL 字符串的域部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何重置 iPhone 应用的钥匙串? 下一篇:MKOverlay 无法顺利调整大小

                  相关文章

                  <legend id='Pnyl2'><style id='Pnyl2'><dir id='Pnyl2'><q id='Pnyl2'></q></dir></style></legend>
                    <bdo id='Pnyl2'></bdo><ul id='Pnyl2'></ul>

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

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

                      <tfoot id='Pnyl2'></tfoot>