{"id":12498,"date":"2015-10-11T21:05:10","date_gmt":"2015-10-12T01:05:10","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=12498"},"modified":"2015-10-11T21:05:11","modified_gmt":"2015-10-12T01:05:11","slug":"nsdata-my-old-friend","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/10\/11\/nsdata-my-old-friend\/","title":{"rendered":"NSData, My Old Friend"},"content":{"rendered":"<p><a href=\"http:\/\/robnapier.net\/nsdata\">Rob Napier<\/a>:<\/p>\n<blockquote cite=\"http:\/\/robnapier.net\/nsdata\">\n<p>I see a lot of Swift devs behaving as though Cocoa has somehow disappeared. Cocoa has become the embarrassing uncle that no one wants to acknowledge, even though he&rsquo;s sitting right there at Thanksgiving dinner passing you the potatoes. And this is crazy. First, Cocoa is a <em>great<\/em> framework, filled with all kinds of tools that we use every day, implemented well and refined for years. And second, Cocoa is a <em>required<\/em> framework, filled with tools that we <em>have<\/em> to use every day if we want to write apps.<\/p>\n<p>[&#8230;]<\/p>\n<p>This &ldquo;but is it correct?&rdquo; came up all over the place. Would this operation cause a copy? Exactly how long is an <code>UnsafeBufferPointer<\/code> valid? There&rsquo;s a lot of bridging magic in <code>Array<\/code>, and it&rsquo;s not always clear what is <em>promised<\/em>. Testing only gets you so far if the current implementation just happens to work. Sometimes behaviors change just by importing Foundation.<\/p>\n<p>[&#8230;]<\/p>\n<p>In the end, I spent hours trying to be certain of the precise behaviors of <code>Array<\/code> bridging and copying. And all that to replace <code>NSData<\/code> code that is perfectly fine.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Rob Napier: I see a lot of Swift devs behaving as though Cocoa has somehow disappeared. Cocoa has become the embarrassing uncle that no one wants to acknowledge, even though he&rsquo;s sitting right there at Thanksgiving dinner passing you the potatoes. And this is crazy. First, Cocoa is a great framework, filled with all kinds [&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,31,46,30,54,71,901],"class_list":["post-12498","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-languagedesign","tag-mac","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12498","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=12498"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12498\/revisions"}],"predecessor-version":[{"id":12499,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/12498\/revisions\/12499"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=12498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=12498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=12498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}