Answer the question
In order to leave comments, you need to log in
How to call a function from another class that has no type?
I can't figure out what the problem is. How to call a function that has no type at all to print text? "Instance member 'mustprint' cannot be used on type 'Printer'; "
ViewController.swift
class ViewController: UIViewController {
@IBAction func action (sender: UIButton) {
Printer.mustprint() //не билдит
}
}
Printer.swift
class Printer: ViewController {
func mustprint() {
print ("was printed")
}
}
Answer the question
In order to leave comments, you need to log in
Are you sure you know the Swift language? Judging by the code and the question - no.
You need to understand what a type method is and what an instance method is.
The type method is defined like this. The static keyword can be replaced with class (but that doesn't matter)
class Printer {
static func mustprint() {
print ("was printed")
}
}
class Printer {
func mustprint() {
print ("was printed")
}
}
in main.css on line 4834 change the width to 100% and remove the margins
.right-col {
float: none;
margin: 0 auto;
margin-right: 40px;
width: 400px;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question