Why “loadNibNamed” methods return array?

后端 未结 3 951
轮回少年
轮回少年 2021-01-21 12:37

When we use the loadNibNamed method to get nib file, why will return a array, is not a nib file name corresponds to a nib file? I try to print this array\'s count, I found it al

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 13:19

    Thanks to the discussion here:

    This is a legacy design left over from the early days of ProjectBuilder/PBX/Interface Builder. I would strongly not recommend this approach and just use separate xib files. I do not see any benefit.

    However if decided to still do it, you can have multiple views as such.

    And access View with .first or [0], view-2 with [1] and so on. Having that said in the comments JAL has said it's not guaranteed to return the indexes correctly and it's better to switch, filter or use tags for the views.

提交回复
热议问题