NSNotificationCenter vs delegation - which is faster?

前端 未结 7 1541
不知归路
不知归路 2020-12-16 16:15

I have read a lot about the pros and cons of each , and i know delegates are usually for one listener, and notifications are for many. The question is about performance.

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 17:08

    Calling the delegate is just a method invocation but when notifications are used there some more stuff should be done behind the scenes to deliver your notification. Considering this - delegate is a bit faster.

    Realtime audio processing is a complex task and I tend to think that delegate's method call or sending a notification produces much more less overhead than your audio-processing code.

    UPDATE

    Considering performance issues you always should do measurements while trying different approaches.

提交回复
热议问题