Reputation: 8516
Which framework need to import to solve the below compile time error in swift :-
Use of undeclared type "Date'
Upvotes: 1
Views: 3379
Reputation: 5602
As you mentioned Swift 2.0 in your tags. So simply use this :
First import this framework in your class:
import Foundation
Than :
func hours(fromdate: NSDate) -> Int {
// your code
}
Important note :
Hope it will guide you.
Upvotes: 4
Reputation: 3219
In Swift 3.0 apple removed the NS prefix ,if you are used Xcode8 with beta 4 and above you can use this
func hours(fromdate: Date) -> Int {
// Your code
}
If you are used in below Swift3 then we need to use NSxxx instead of all
func hours(fromdate: NSDate) -> Int {
// Your code
}
Upvotes: 4
Reputation: 107141
The Date class is introduced in Swift 3.0 & Xcode 8. So you won't get it in Swift 2.2 version. You need to use NSDate
instead.
In Swift 3.0 apple removed the NS
prefix from the classes.
NSDate
became Date
NSCalendar
became Calendar
Upvotes: 2