Passing Data through NSTimer UserInfo

后端 未结 6 1881
抹茶落季
抹茶落季 2021-01-31 09:18

I am trying to pass data through userInfo for an NSTimer call. What is the best way to do this? I am trying to use an NSDictionary, this is simple enough when I have Objective-C

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 09:58

    You should not cast your objects to id when assigning to the dictionary. Any object that can be embedded directly into a NSDictionary already derives from NSObject and are implicitly concidered cast to id. Store the name of the selector as an NSString (using NSStringFromSelector()) and then convert it back to a selector using NSSelectorFromString()

    Claus

提交回复
热议问题