【发布时间】:2016-02-13 14:38:17
【问题描述】:
我有两个课程:
//This is my custom class, where I would like to get access to 'MyTableView' class
import UIKit
class TestClass: NSObject {
//Instance variable 'myTableView'
var myTableView: MyTableView!
override init() {
super.init()
//Creat an instance!
myTableView = MyTableView()
}
func ReloadTableView() {
//Reload the current TableView
myTableView.MyTableView.reloadData()
}
//My functions...
}
//This is 'MyTableView' class which is connected to a TableViewController in storyboard. When I open the corresponding TableView in my App, the viewDidLoad function is called.
import UIKit
class MyTableView: UITableViewController {
@IBOutlet var MyTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
//Functions to creat the current TableView with it's information...
}
我的问题:
为什么我无法从“TestClass”访问“MyTableView”类?我总是得到例外:
在展开可选值时意外发现 nil
是否有可能获得有关活动视图的信息? 谢谢!
【问题讨论】:
标签: swift uitableview uiview uiviewcontroller