When to use a colon with a @selector

前端 未结 6 1222
傲寒
傲寒 2020-12-03 04:10

Just getting going with iPhone development and Objective-C.

Yesterday I was trying to addObserver for a notification in a view of mine, and I kept getti

6条回答
  •  失恋的感觉
    2020-12-03 04:35

    As mentioned by boltClock, the character you are referring to is actually a colon. The difference between @selector(method) and @selector(method:) is the method signature. The 2nd variant expects a parameter to be passed.

    @selector(method) would expect the method: -(void)method

    @selector(method:) would expect the method: -(void)method:(id)someParameter

提交回复
热议问题