gpt4 book ai didi

ios - 是否可以隐藏类的继承?

转载 作者:可可西里 更新时间:2023-11-01 06:23:14 25 4
gpt4 key购买 nike

从外面看,我希望我的类(class)看起来像这样

@interface MYCardGroupView : UIView
@property (nonatomic, strong) NSArray *cardObjects;
@end

但在类本身中我希望它实际上是一个 UITableView

@interface MYCardGroupView : UITableView <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *cardObjects;
@end

参数:

  • 从 API 的角度来看,只显示必要的接口(interface)是有意义的
  • 将 UITableView 作为 subview 只是为了保持界面不臃肿感觉非常过分(干净的界面 vs 具有更深 View 树的性能成本)

最佳答案

理论上,可以使用两个单独的 .h 文件,一个是“真实的”文件,仅名为“MyClass_real.h”,另一个是假的,名为“MyClass.h”。在您的 .m 中包含真实的,但使用假的作为广告接口(interface)。假的可能会说您的基类是“土 bean ”,这不会有任何区别。

(我想人们必须对 ARC 有点担心。它可能会变得不安。)

关于ios - 是否可以隐藏类的继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20979703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com