{"id":8016,"date":"2013-10-15T17:47:57","date_gmt":"2013-10-15T22:47:57","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8016"},"modified":"2013-10-15T18:45:55","modified_gmt":"2013-10-15T23:45:55","slug":"ksurlcomponents","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/10\/15\/ksurlcomponents\/","title":{"rendered":"KSURLComponents"},"content":{"rendered":"<p><a href=\"http:\/\/www.mikeabdullah.net\/ksurlcomponents.html\">Mike Abdullah<\/a>:<\/p><blockquote cite=\"http:\/\/www.mikeabdullah.net\/ksurlcomponents.html\"><p>I daresay Apple faced this same decision. NSMutableURL initially makes the most sense as a companion to all the NSMutable<em>Foo<\/em> classes in Foundation. But closer inspection reveals the awkward problem that many mutations cannot result in a valid URL. For example, trying to specify a relative path is only allowed if there&rsquo;s no scheme or authority component. That then leaves our theoretical NSMutableURL class with having to throw exceptions, throw away data, or exist in some unusual invalid state when such a mutation is requested. And don&rsquo;t even get started on handling URL schemes that don&rsquo;t conform to <a href=\"http:\/\/www.ietf.org\/rfc\/rfc1808.txt\">RFC 1808<\/a>&#8230;<\/p><p>Instead, NSURLComponents &mdash; along the same lines as NSDateComponents &mdash; probably makes the most sense. All mutations are legal, and -URL will simply return nil until a valid combination of components is specified.<\/p><\/blockquote><p><code>NSURLComponents<\/code> is great, but it&rsquo;s not available on Mac OS X 10.8 or iOS 6, hence his <a href=\"https:\/\/github.com\/karelia\/KSFileUtilities#ksurlcomponents\">clone<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Mike Abdullah:I daresay Apple faced this same decision. NSMutableURL initially makes the most sense as a companion to all the NSMutableFoo classes in Foundation. But closer inspection reveals the awkward problem that many mutations cannot result in a valid URL. For example, trying to specify a relative path is only allowed if there&rsquo;s no scheme [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,54,74,71,489],"class_list":["post-8016","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-objective-c","tag-opensource","tag-programming","tag-url"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=8016"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8016\/revisions"}],"predecessor-version":[{"id":8018,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8016\/revisions\/8018"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}