KVO's docs on removeObserver:forKeyPath: should mention that it raises an exception if it's not already observing.
| Originator: | robotspacer | ||
| Number: | rdar://16593557 | Date Originated: | 11-Apr-2014 02:18 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | N/A |
| Classification: | Enchancement | Reproducible: | N/A |
There are many cases where you might be using NSNotificationCenter to observe NSUserDefaultsDidChangeNotification, but wish you could know exactly what defaults are changing, or what their new values are. No problem, you think: I'll ask the internet! The internet might point you toward Key Value Observing, and all the magical things it can do. But the internet might not tell you all the ways in which it can crash. It's cool though, you think. This is really similar to NSNotificationCenter, and occasionally calling removeObserver: needlessly doesn't cause any problems there. Plus, the docs would tell me if something would raise an exception. The docs *love* to tell me if something could raise an exception. So then you ship your app, and someone comes across that rare timing bug that causes the remove code to get called first, and now you have to rewrite a bunch of code, or just add a bunch of try/catch garbage all over the place. It sure would've been nice if you'd known about that sooner. Steps to Reproduce: N/A Expected Results: N/A Actual Results: N/A
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!