Checking if a .nib or .xib file exists

后端 未结 3 1866
走了就别回头了
走了就别回头了 2020-12-14 07:03

What\'s the best way to check if a Nib or Xib file exists before trying to load it using initWithNibName:bundle: or similar?

3条回答
  •  长情又很酷
    2020-12-14 07:32

    Solution For swift :

    guard Bundle.main.path(forResource: "FileName", ofType: "nib") != nil else {
       ...
    }
    

提交回复
热议问题