从另一个文件加载Split View Controller的列表

时间:2016-02-03 10:50:44

标签: ios swift

这段代码效果很好。 但我想从(例如)文件1加载类别名称从(例如)文件2

加载
// MARK: - Properties
var detailViewController: DetailViewController? = nil
var candies = [Candy]()
var filteredCandies = [Candy]()
let searchController = UISearchController(searchResultsController: nil)

// MARK: - View Setup
override func viewDidLoad() {
 super.viewDidLoad()

 // Setup the Search Controller
 searchController.searchResultsUpdater = self
 searchController.searchBar.delegate = self
 definesPresentationContext = true
 searchController.dimsBackgroundDuringPresentation = false

 // Setup the Scope Bar
 searchController.searchBar.scopeButtonTitles = ["All", "Chocolate", "Hard", "Other"]
 tableView.tableHeaderView = searchController.searchBar

 candies = [
  Candy(category:"Chocolate", name:"Chocolate Bar"),
  Candy(category:"Chocolate", name:"Chocolate Chip"),
  Candy(category:"Qukullad", name:"keks")]

 if let splitViewController = splitViewController {
  let controllers = splitViewController.viewControllers
  detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
 }
}

0 个答案:

没有答案