iOS:创建许多IBOutlet会产生性能开销吗?

问题描述 投票:0回答:2

如果我们从情节提要/ xib到ViewController / View创建许多IBOutlet,那么会导致性能开销吗?如果可以,怎么办?

ios objective-c swift xcode storyboard
2个回答
0
投票

是。这就是为什么您应该根据自己的目的创建许多情节提要的原因。例如:设置情节提要,主情节提要,用户情节提要,选取器情节提要。


0
投票

请参阅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.

因此会导致性能开销。

有关更多详细信息,请参见文档。

© www.soinside.com 2019 - 2024. All rights reserved.