如何包含位于不同组中的Swift文件?

时间:2015-01-29 21:19:37

标签: ios swift

我有这样的结构:

A file tree with the root and a single subdirectory named "Views". In Views are two files named DropDownPlayView.xib and SlidePlayView.xib, respectively. In the root directory is one file named AppDelegate.swift.

我的问题很简单。 如何在SlidePlayView内创建AppDelegate类型的变量?

1 个答案:

答案 0 :(得分:1)

我不知道SlidePlayView.xib是否包含视图,但如果它包含,如果xib包含正确的视图作为其第一个对象,则以下内容应该有效:

let slidePlayView  = NSBundle.mainBundle().loadNibNamed("SlidePlayView", owner: self, options: nil)[0] as SlidePlayView