NSOperation should clear completionBlock after running

Originator:steipete
Number:rdar://32541724 Date Originated:02-Jun-2017 12:34 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:10.3.2
Classification:Other Bug Reproducible:Always
 
Summary:
NSOperation promises to clear the completionBlock after running:

>In iOS 8 and later and macOS 10.10 and later, this property is set to nil after the completion block begins executing.

However, this is not true for iOS, it only happens on macOS.

Steps to Reproduce:
Run attached samples (one for iOS, one for macOS)
Observe output.

Expected Results:
Log:
Optional((Function))
nil
nil
nil


Actual Results:
iOS 10.3.2:

Optional((Function))
Optional((Function))
Optional((Function))
nil

macOS 10.12.5:
Optional((Function))
nil
nil
nil


Version:
10.3.2

Notes:
Not sure if this is a regression or never worked on iOS. You can also test this in a Playground: https://gist.github.com/bjhomer/e866a405c425e83c8cad53a8ee8f055e

Comments

I talked to an engineer at WWDC 2017 and this will be fixed in iOS 11 b2.

Samples: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/32541724%20-%20CompletionBlockClearingForNSOperation


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!