<html><body><div>Hello all,</div><div><br data-mce-bogus="1"></div><div>I have just discovered following behaviour of NSURLComponents and I'm looking for confirmation if it is in fact a bug.</div><div><br data-mce-bogus="1"></div><div><p class="p1" style="padding-left: 24px;" data-mce-style="padding-left: 24px;"><span style="font-family: 'courier new', monospace;" data-mce-style="font-family: 'courier new', monospace;"><span class="s1">var</span><span class="s2"> components = </span><span class="s3">NSURLComponents</span><span class="s2">(string: </span><span class="s3">"apple.com"</span><span class="s2">)!</span></span></p><p class="p3" style="padding-left: 24px;" data-mce-style="padding-left: 24px;"><span style="font-family: 'courier new', monospace;" data-mce-style="font-family: 'courier new', monospace;"><span class="s3">components</span><span class="s2">.</span><span class="s3">scheme</span><span class="s2"> = </span><span class="s4">"http"</span></span></p><p class="p3" style="padding-left: 24px;" data-mce-style="padding-left: 24px;"><span style="font-family: 'courier new', monospace;" data-mce-style="font-family: 'courier new', monospace;"><span class="s1">print</span><span class="s2">(</span><span class="s3">components</span><span class="s2">.</span><span class="s3">scheme</span><span class="s2">) // prints "Optional("http")\n"</span></span></p><p class="p3" style="padding-left: 24px;" data-mce-style="padding-left: 24px;"><span style="font-family: 'courier new', monospace;" data-mce-style="font-family: 'courier new', monospace;"><span class="s1">print</span><span class="s2">(</span><span class="s3">components</span><span class="s2">.</span><span class="s3">URL</span><span class="s2">?.</span><span class="s3">absoluteURL</span><span class="s2">) // prints ""Optional(http:apple.com)\n", <strong>I'd expect </strong><meta charset="utf-8"><span style="color: rgb(0, 0, 0); font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important; background-color: rgb(255, 255, 255);" data-mce-style="color: #000000; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important; background-color: #ffffff;"><strong>http://apple.com</strong></span></span></span></p><p class="p3"><span class="s2"><br data-mce-bogus="1"></span></p><p class="p3"><span class="s2">When trying to set scheme as "http://" I get an error which is in line with what documentation says. So it seems there is no way of setting the scheme after URLComponents initialisation and getting correct URL as a result.</span></p><p class="p3"><span class="s2"><br data-mce-bogus="1"></span></p><p class="p3"><span class="s2">Any thoughts?</span></p><p class="p3"><span class="s2">Regards,</span></p><p class="p3"><span class="s2">MichaĆ Kalinowski</span></p></div></body></html>