【发布时间】:2015-09-24 02:02:16
【问题描述】:
我有一个返回 NSArray 的函数,如下所示
func papulateViewControllers() -> NSArray{
let chatVC = ChatsVC(nibName:"ChatsVC", bundle:NSBundle.mainBundle())
let contactVC = ContactsVC(nibName:"ContactsVC", bundle:NSBundle.mainBundle())
let notificationVC = NotificationsVC(nibName:"NotificationsVC", bundle:NSBundle.mainBundle())
let chatNav = UINavigationController()
chatNav.viewControllers = [chatVC]
let contactNav = UINavigationController()
contactNav.viewControllers = [contactVC]
let notifNav = UINavigationController()
notifNav.viewControllers = [notificationVC]
return [chatNav, contactNav, notifNav]
}//end papulateViewControllers
我是这样调用这个方法的
var tabs = UITabBarController()
tabs.viewControllers = papulateViewControllers() as [AnyObject]
但是我收到了这个错误 无法将“[AnyObject]”类型的值分配给“[UIViewController]”类型的值?
需要建议来修复此错误,并优化上述功能。
【问题讨论】: