{"id":28839,"date":"2020-05-04T13:43:40","date_gmt":"2020-05-04T17:43:40","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=28839"},"modified":"2020-05-19T15:51:30","modified_gmt":"2020-05-19T19:51:30","slug":"nsprogress-documentation-conflicts","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/05\/04\/nsprogress-documentation-conflicts\/","title":{"rendered":"NSProgress Documentation Conflicts"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/parrots\/status\/1183798997770747904\">Curtis Herbert<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/parrots\/status\/1183798997770747904\">\n<p>Wait...what? The new <code>NSProgress<\/code> stuff on <code>NSOperationQueue<\/code> says you have to call <code>super.start()<\/code> to contribute towards progress, but Foundation docs for <code>NSOperation<\/code> say to never call <code>super.start()<\/code> O.o<\/p>\n<\/blockquote>\n\n<p>NSOperation.h:<\/p>\n<blockquote><p>The <code>progress<\/code> property represents a total progress of the operations executed in the queue. By default NSOperationQueue does not report progress until the <code>totalUnitCount<\/code> of the progress is set. When the <code>totalUnitCount<\/code> property of the progress is set the queue then opts into participating in progress reporting. When enabled, each operation will contribute 1 unit of completion to the overall progress of the queue for operations that are finished by the end of main (operations that override <code>start<\/code> and do not invoke <code>super<\/code> will not contribute to progress).<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsoperation\">NSOperation documentation<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsoperation\"><p>At no time in your <code>start<\/code> method should you ever call <code>super<\/code>. When you define a concurrent operation, you take it upon yourself to provide the same behavior that the default <code>start<\/code> method provides, which includes starting the task and generating the appropriate KVO notifications.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/bukovinski\/status\/1256176454615945218\">Matej Bukovinski<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/bukovinski\/status\/1256176454615945218\">\n<p>Let&rsquo;s just replace a <code>NSProgress<\/code> helper with built-in API. Easy. A day later we&rsquo;re still trying to figure out if we even know how this API is supposed to be used. <em>Spoiler:<\/em> The header is right. As usual. Never rely just on the generated docs.<\/p>\n<\/blockquote>\n\n<p>NSProgress.h:<\/p>\n<blockquote><p><code>-isIndeterminate<\/code> returns <code>YES<\/code> when the value of the <code>totalUnitCount<\/code> or <code>completedUnitCount<\/code> property is less than zero. Zero values for both of those properties indicates that there turned out to not be any work to do after all; <code>-isIndeterminate<\/code> returns <code>NO<\/code> and <code>-fractionCompleted<\/code> returns 1.0 in that case.<\/p><\/blockquote>\n\n<p><a href=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsprogress\/1412871-indeterminate\">NSProgress documentation<\/a>:<\/p>\n<blockquote cite=\"https:\/\/developer.apple.com\/documentation\/foundation\/nsprogress\/1412871-indeterminate\"><p>Progress is indeterminate when the value of both <code>totalUnitCount<\/code> and <code>completedUnitCount<\/code> are zero.<\/p><\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2014\/03\/13\/nsprogress\/\">NSProgress<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/01\/25\/an-example-on-how-to-use-nsprogress\/\">An Example on How to Use NSProgress<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/08\/31\/nsprogress-enhancements\/\">NSProgress Enhancements<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2017\/08\/01\/nsprogress-shortcomings-and-csprogress\/\">NSProgress Shortcomings and CSProgress<\/a><\/li>\n<\/ul>\n\n<p id=\"nsprogress-documentation-conflicts-update-2020-05-06\">Update (2020-05-06): <a href=\"https:\/\/twitter.com\/steipete\/status\/1257332404580122624\">Peter Steinberger<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/steipete\/status\/1257332404580122624\"><p>UIKit folks, there&rsquo;s a <a href=\"https:\/\/openradar.appspot.com\/36129961\">radar from 2017<\/a> about wrongly documented <code>NSProgress<\/code> API.<\/p><\/blockquote>\n\n<p id=\"nsprogress-documentation-conflicts-update-2020-05-19\">Update (2020-05-19): <a href=\"https:\/\/twitter.com\/noahsark769\/status\/1258461207003926528\">Noah Gilmore<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/noahsark769\/status\/1258461207003926528\">\n<p>Oh man, this just reminded me of a nasty customer-facing issue we fixed with <code>NSProgress<\/code>. Turns out that if you set <code>completedUnitCount<\/code> too many times on a background thread, app&rsquo;s memory <a href=\"https:\/\/stackoverflow.com\/questions\/35386209\/massive-memory-growth-with-nsprogress\">grows uncontrollably<\/a> and eventually hits the memory limit &#x1F628;<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Curtis Herbert: Wait...what? The new NSProgress stuff on NSOperationQueue says you have to call super.start() to contribute towards progress, but Foundation docs for NSOperation say to never call super.start() O.o NSOperation.h: The progress property represents a total progress of the operations executed in the queue. By default NSOperationQueue does not report progress until the totalUnitCount [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2020-05-04T17:43:43Z","apple_news_api_id":"4788e730-75c1-4e91-9ee4-bc1bcfd044c2","apple_news_api_modified_at":"2020-05-19T19:51:33Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAw==","apple_news_api_share_url":"https:\/\/apple.news\/AR4jnMHXBTpGe5Lwbz9BEwg","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,164,31,1667,30,1666,1549,71],"class_list":["post-28839","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-documentation","tag-ios","tag-ios-13","tag-mac","tag-macos-10-15","tag-nsprogress","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28839","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=28839"}],"version-history":[{"count":5,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28839\/revisions"}],"predecessor-version":[{"id":28979,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/28839\/revisions\/28979"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=28839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=28839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=28839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}