zoukankan      html  css  js  c++  java
  • NSURL基本操作 HA

    When working with NSURL objects, often times there are a number of values passed along with the URL. For example, a query string is often included as a means to embed HTML form data. This tip shows how to parse and print the values of a URL.

    The code below begins by defining a URL and is followed by logging the url values to the debug console:

    NSURL *url = [NSURL URLWithString:  @"http://some-site.com:999/dir1/dir2;param?field-1=value-1&field-2=value-2#anchor1"];   NSLog(@"Scheme: %@", [url scheme]);  NSLog(@"Host: %@", [url host]);  NSLog(@"Port: %@", [url port]);      NSLog(@"Path: %@", [url path]);      NSLog(@"Relative path: %@", [url relativePath]); NSLog(@"Path components as array: %@", [url pathComponents]);         NSLog(@"Parameter string: %@", [url parameterString]);    NSLog(@"Query: %@", [url query]);        NSLog(@"Fragment: %@", [url fragment]);

    The output is shown below:

  • 相关阅读:
    the Agiles Scrum Meeting 8
    the Agiles Scrum Meeting 7
    the Agiles Scrum Meeting 6
    项目使用说明——英文版
    第十次例会
    第九次例会
    第八次例会
    第六次例会
    第七次例会
    第五次例会
  • 原文地址:https://www.cnblogs.com/halou/p/2054990.html
Copyright © 2011-2022 走看看