Answer the question
In order to leave comments, you need to log in
Swift Classes Initialization Import - ?
Comrades, explain to an incomprehensible person in an intelligible language.
1) It is not necessary to import classes in Swift3, are they added themselves?
2) Why does this not work:
file test.swift
class Dog {
func bark() {
print("woof") // This is a comment
}
}
class ViewController: UIViewController {
let kit = Dog()
kit.bark()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
Answer the question
In order to leave comments, you need to log in
I have not dealt with Swift yet, but it seems to me that
let kit = Dog()
kit.bark()
Within the application code, classes do not need to be imported, because they are all considered inside the same module, so they see each other, but if you add another application to yours, then you already need to do import.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question