: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
| | | | | | | | |
| | | | | | | | |
: [ ? ] [ # ]
, HTTP , , , :
foo:// username: password @ example.com :8042 /over/there/index .dtb ?type=animal&name=narwhal #nose scheme username password hostname port path extension query fragment
URL . URI .
Foundation URL' NSURL .
NSURL URLWithString :
NSURL *url = [NSURL URLWithString:@"http://example.com"];
By the way, what do you think about using @@ as a literal for NSURL (i.e. @@ "http://example.com")?
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
Separately, it must be said that although the username and password can be stored in the URL , it is better to use NSURLCreditnal or store them in a keychain.
Attempting to set the wrong scheme or select a negative number for the port will result in an exception.
Upon receipt of these properties, we get them in the percent-encoded form. Changing these properties you need to give the already enveloped line, otherwise - the exception. `;` - is a valid character, but it is also recommended to encode it for better compatibility with NSURL . ( -stringByAddingPercentEncodingWithAllowedCharacters: zankodit all `;` if you pass the URLPathAllowedCharacterSet )
CFStringRef CFURLCreateStringByAddingPercentEscapes ( CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding );
CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding ( CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding );
A bookmark is a closed file structure, which is enclosed in an NSData object; it describes the location of the file. While the path and reference URL are potentially unreliable, a bookmark can be used to recreate the URL , even if the file has been moved or renamed.
Source: https://habr.com/ru/post/225969/
All Articles