Understanding uniqueness of selectors in Objective-C

前端 未结 4 1605
死守一世寂寞
死守一世寂寞 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:10

    Look at the SEL type, you don't have to define which class this selector is from, you just give it a method name, for example:

    SEL animationSelector = @selector(addAnimation:forKey:); 
    

    You can imagine it as a streetname, for example. Many cities can have the same streetnames, but a streetname without a city is worthless. Same for selectors, you can define a selector without adding the object where it's in. But it's complete worthless without fitting class..

提交回复
热议问题