ios - 我可以将选择器作为 iOS 中的属性吗?

标签 ios objective-c

我可以在 iOS 中将选择器作为属性吗? 像这样:

@property (nonatomic, strong) SEL *mySelector;

最佳答案

当然可以,但不是strong,因为它不是对象类型。

另外 SEL 不应该是一个指针(除非你真的是这个意思)

@property (nonatomic) SEL mySelector;

作为奖励,这里是 SEL 类型的实际定义,取自 objc.h

/// An opaque type that represents a method selector.
typedef struct objc_selector *SEL;

关于ios - 我可以将选择器作为 iOS 中的属性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22152950/

相关文章:

android - 应用在元数据中包含对 Android 的引用

iOS - 如何启用与 WebView 的用户交互

ios - glclear() 在 ios8 opengl 中修改 glscissor() 边界之外的图像

ios - WatchKit App 只返回一些 HealthKit 数据

ios - 在 iOS 中从 HTML 文件中查找嵌入的 Flash 内容

ios - 预加载 SKTextures/SKTextureAtlas 困惑

ios - 使用属性文本修改下划线的宽度?

iOS:了解导航推送后何时加载两个 View Controller 的最佳实践

ios - 从 2013 年 10 月起无法从 Graph API 获取 "access token"

ios - 在 AVPlayerViewController 中禁用手势识别器