views:

123

answers:

1

Should I be afraid of using Key-Value Observations (KVO) and NSNotifications? I'm beginning to use them in my app, but I'm a little unfamiliar with the concept of something that could possibly be triggering an appwide call or automatically doing stuff, and a little afraid of the performance hit that such overhead could bring.

Are my concerns unfounded? Should I use them just like any other method call? They seem very convenient and fill a lot of gaps, so I'd like to use them if possible. Note: I am programming primarily for iOS devices, so performance is always a concern for me.

+6  A: 

Both Key-Value observers and NSNotifications are pretty light-weight and were just fine on desktop machines that had less power than an iPad. That said, performance questions of the "should I?" type can only be answered by profiling. I think you'll find most folks would recommend, abscent any specific performance requirements that require up-front design, you write the app in the way that makes most sense architecturally and is most efficient for development. Then profile, profile, profile. If you find that KVO or notifications are taking a significant amount of your apps time (I doubt that will be the case), then consider more performant solutions (though there aren't many).

Barry Wark
Thanks for the quick answer. I guess I was just being a little paranoid. I tend to do a lot of profiling on my apps, probably too much for my own good.
David Liu