【问题标题】:iOS: Creating many IBOutlets has performance overhead?iOS:创建许多 IBOutlets 有性能开销吗?
【发布时间】:2020-08-30 11:34:38
【问题描述】:

如果我们从 storyboard/xib 到 ViewController/View 创建了许多 IBOutlet,那么会不会导致性能开销?如果有怎么办?

【问题讨论】:

    标签: ios objective-c swift xcode storyboard


    【解决方案1】:

    请参阅 Apple Developer 中的 IBOutlet 定义。

    这里是Outlets documentation link

    我们可以看到这个

    the more outlets an object has, the more memory it takes up. 
    If there are other ways to obtain a reference to an object, 
    such as finding it through its index position in a matrix, 
    or through its inclusion as a function parameter, 
    or through use of a tag (an assigned numeric identifier), 
    you should do that instead.
    

    所以会造成性能开销。

    更多详情,您可以查看文档。

    【讨论】:

      【解决方案2】:

      是的。这就是为什么您应该根据您的目的创建许多故事板。 例如:设置 Storyboard、Main Storyboard、User Storyboard、Picker Storyboard。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-18
        • 2023-03-21
        • 2011-04-25
        • 1970-01-01
        • 2015-04-28
        • 2012-01-05
        相关资源
        最近更新 更多