multiple listeners for delegate iOS

前端 未结 3 1887
抹茶落季
抹茶落季 2021-02-14 10:20

I have a class search bar with a delegate didSelectString. I have an class A that implements the delegate and a class B that implements the delegate.

However only the de

3条回答
  •  悲哀的现实
    2021-02-14 11:13

    Create a small new class called Delegates. Have it adopt the search bar protocol so it can be the primary search bar delegate. Have this class offer a method 'addSearchBarDelegate:', in which it will add the delegate to a mutable array. When it gets a delegate message, it forwards it to each registered delegate.

提交回复
热议问题