Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the "Use of undeclared type UITableView" happened in Swift?

I am new to Swift. I created a second swift file call DeviceInfo.swift and add a UIViewcontroller in Main.storyboard.

I also add a UITableView in UIViewcontroller(DeviceInfo).

But the error Use of undeclared type 'UITableView' show after I connect the UITableView to DeviceInfo.swift via command + left. The error show like the following. enter image description here

Question

1. Why the Use of undeclared type 'UITableView' happened ? How to solve it ?

2. Show I connect the dataSource and delegate to UIViewcontroller(DeviceInfo)?

Thanks in advance.

like image 305
Martin Avatar asked Jan 19 '15 03:01

Martin


2 Answers

1.import UIKit

2.To connect delegate and dataSource, click the point and drag to your tableView. enter image description here

like image 64
Zigii Wong Avatar answered Oct 16 '22 14:10

Zigii Wong


You need to add import UIKit at the top of your file, in the area where you've already got import Foundation. Without UIKit imported, your object doesn't know what a UITableView is.

like image 36
Duncan Babbage Avatar answered Oct 16 '22 15:10

Duncan Babbage