ThreadedCoreData is not calling removeObserver:forKeyPath: or removeObserver:forKeyPath:context:

Originator:max.zou.se
Number:rdar://27842894 Date Originated:15-Aug-2016
Status:Open Resolved:
Product:Sample Code Product Version:
Classification: Reproducible:Always
 
Chaoqun Zou15-Aug-2016 03:43 PM

Summary:
The sample code ThreadedCoreData (https://developer.apple.com/library/ios/samplecode/ThreadedCoreData/Introduction/Intro.html) uses KVO to listen for incoming earthquakes from our data source using KVO and listen for errors reported by our data source using KVO, so we can report it in our own way.

According to the NSKeyValueObserving Protocol Reference: An object that calls 
the addObserver:forKeyPath:options:context: method must also call either the removeObserver:forKeyPath: or removeObserver:forKeyPath:context: method when participating in KVO. However in the ThreadedCoreData neither method is used throughout the project.

Steps to Reproduce:
1 Check the sample project "APLViewController.m" line 45 and line 48 where addObserver:forKeyPath:options:context: is used
2 Search removeObserver:forKeyPath: throughout the project and it is not used at all
3 Check NSKeyValueObserving Protocol Reference, it states: An object that calls this method must also call either the removeObserver:forKeyPath: or removeObserver:forKeyPath:context: method when participating in KVO.

Expected Results:
The ThreadedCoreData sample should call either the removeObserver:forKeyPath: or removeObserver:forKeyPath:context: method in an appropriate place.

Actual Results:
The ThreadedCoreData sample does not call  either the removeObserver:forKeyPath: or removeObserver:forKeyPath:context: method

Version:
https://developer.apple.com/library/ios/samplecode/ThreadedCoreData/Introduction/Intro.html

Notes:
Apple sample code should demonstrate the correct usage of all API methods but should not carelessly leave incorrect API uses. If the documentation is out of dated the documentation should be updated.

Configuration:
Xcode 7.3.1

Attachments:

Comments


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!