{"id":10602,"date":"2015-01-25T20:09:58","date_gmt":"2015-01-26T01:09:58","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10602"},"modified":"2017-08-01T14:49:55","modified_gmt":"2017-08-01T18:49:55","slug":"an-example-on-how-to-use-nsprogress","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/01\/25\/an-example-on-how-to-use-nsprogress\/","title":{"rendered":"An Example on How to Use NSProgress"},"content":{"rendered":"<p><a href=\"http:\/\/jaanus.com\/blog\/2015\/01\/24\/an-example-on-how-to-use-nsprogress\/\">Jaanus Kase<\/a> (via <a href=\"https:\/\/twitter.com\/olebegemann\/status\/559113324265476096\">Ole Begemann<\/a>):<\/p>\n<blockquote cite=\"http:\/\/jaanus.com\/blog\/2015\/01\/24\/an-example-on-how-to-use-nsprogress\/\">\n<p>The best I can tell, there is no way to do this in Swift that does not look insane and ridiculous. See, <code>-[NSWindowController initWithWindowNibName:]<\/code> is a <em>convenience<\/em> initializer on NSWindowController, and Swift is much more restrictive about its initialization behavior in this case. You can&rsquo;t call the parent&rsquo;s convenience initializer from your own designated initializer.<\/p>\n<p>[&#8230;]<\/p>\n<p>Now, I was able to fix my demo project because it is a small, tightly controlled thing. I can be pretty sure that no other unwanted stuff is running after I fixed the above (first show window, and only then become the current progress object). But this might not be feasible for bigger projects where more things are happening at the same time and you don&rsquo;t have tight control over all of them. Like, during the time where you are the current progress object, can you guarantee that nobody in your app is going to read anything from disk?<\/p>\n<p>[&#8230;]<\/p>\n<p>I suppose another solution is what Ole describes, to forgo the whole &ldquo;current progress object&rdquo; business and just pass the parent around between objects, and you can then become a child of that particular one and not just a child of whatever happens to be &ldquo;current&rdquo; at that point. This defeats the &ldquo;loose coupling&rdquo; aspect, though.<\/p>\n<\/blockquote>\n<p>Too bad&mdash;it seemed like such a promising API. He says it&rsquo;s also crashy.<\/p>","protected":false},"excerpt":{"rendered":"<p>Jaanus Kase (via Ole Begemann): The best I can tell, there is no way to do this in Swift that does not look insane and ridiculous. See, -[NSWindowController initWithWindowNibName:] is a convenience initializer on NSWindowController, and Swift is much more restrictive about its initialization behavior in this case. You can&rsquo;t call the parent&rsquo;s convenience initializer [&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":[131,69,46,30,1549,54,71,901],"class_list":["post-10602","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-languagedesign","tag-mac","tag-nsprogress","tag-objective-c","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10602","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=10602"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10602\/revisions"}],"predecessor-version":[{"id":10604,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10602\/revisions\/10604"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}