【问题标题】:Using objc associated objet for an IBOutletCollection将 objc 关联对象用于 IBOutletCollection
【发布时间】:2020-09-10 13:11:04
【问题描述】:

我想在不使用继承的情况下为我的所有 UIViewController 类公开一个 IBOutletCollection,所以我尝试使用 objc 运行时,但从未调用过。知道为什么吗?

@interface UIViewController (MyCategory)

@property (nonatomic, strong) IBOutletCollection(UIView) NSArray<UIView *>    * items;

@end


@implementation UIViewController (MyCategory)

- (void)setItems:(NSArray<UIView *> *)items
{
    objc_setAssociatedObject(self, "items", items, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSArray<UIView *> *)items
{
    return objc_getAssociatedObject(self, "items");
}

@end

【问题讨论】:

    标签: objective-c objective-c-runtime objective-c-category


    【解决方案1】:

    问题解决了,我没有将 IBOutletCollection 用于启用断点的视图控制器:D

    【讨论】:

      猜你喜欢
      • 2012-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多