ios - Is it safe to catch an exception from [NSObject removeObserver:forKeyPath:]? -
i have code uses kvo heavily , have addobserver:forkeypath: , removeobserver:forkeypath: in multiple places. app crash "cannot remove observer key path."
i wondering if safe try/catch exception prevent app crashing. know it's not best approach in handling kvo need buy time before can clean code.
exceptions, internal apple apis, should never silently caught , ignored. in objective-c exception should cause app terminate, unlike other languages , runtimes (java, .net) catching exceptions normal part of development.
if getting crash, have bug somewhere , need fix it. swallowing exception have pretty bad consequences due getting inconsistent state. don't it.
Comments
Post a Comment