From 4665315444c0e3ea42cd5eb651898499e0b32c02 Mon Sep 17 00:00:00 2001 From: Ioannis Kokkinidis Date: Tue, 6 Feb 2018 18:04:00 +0200 Subject: [PATCH] Surrounded the removeObserver call with a try catch block. Fixes: https://github.com/yannickl/YLMoment/issues/38 --- YLMoment/YLMomentObject.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/YLMoment/YLMomentObject.m b/YLMoment/YLMomentObject.m index 64320d4..0251e9e 100644 --- a/YLMoment/YLMomentObject.m +++ b/YLMoment/YLMomentObject.m @@ -54,7 +54,11 @@ - (id)initProxy; @implementation YLMoment - (void)dealloc { - [self removeObserver:self forKeyPath:@"locale"]; + @try { + [self removeObserver:self forKeyPath:@"locale"]; + } @catch(id exception) { + NSLog(@"YLMoment warning: %@", exception); + } } #pragma mark - Creating and Initializing Moment Objects