iOS:创建许多IBOutlet是否会带来性能开销?

时间:2020-05-14 03:28:16

标签: ios objective-c swift xcode storyboard

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

2 个答案:

答案 0 :(得分:3)

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

因此将导致性能开销。

有关更多详细信息,您可以查看文档。

答案 1 :(得分:0)

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