Understanding uniqueness of selectors in Objective-C

前端 未结 4 1603
死守一世寂寞
死守一世寂寞 2021-01-15 03:50

I am having problem understanding part of the function of \"selectors\", as described in Apple\'s guide. I\'ve bolded the parts where I am getting confused:

4条回答
  •  失恋的感觉
    2021-01-15 04:15

    Yes. Classes do share selectors.

    I can give an example from the source code objc-sel.mm, but when you use sel_registerUid() (used behind the scenes in @selector()), It copies the input string into an internal buffer (if the string hasn't been registered before), for which all future SELs point to.

    This is done for less memory usage, and easier message forwarding.

提交回复
热议问题