Swift: how to call a function from another quick file

I have some quick files like UIViewController in my xcode 6 beta-2 project.

Basically I want to know some data from file A for use in file B.

My files are UIViewControllers, and I created a function without parameters that returns a string in UIViewController_A. When I try to call this function in UIViewController_B, intellisense populates it for me, but says that I should have a parameter that is automatically processed as UIViewController_A).

In the code LoginScreen.swift == ViewController_A and ViewResidentsTask == ViewController_B.

My function, called checkPrivs, exists in LoginScreen.swift and looks like this:

func checkPrivs()-> String{
    return userPrivType
}

this is how i think it should be called:

var userType = LoginScreen.checkPrivs()

, intellisense , :

var userType = LoginScreen.checkPrivs(LoginScreen)

: "", "" , LoginScreen, , (, , ), .

Xcode #, .

ANSWER: , 'loginScreen' UIViewController, .

+4
2

LoginScreen :

let login = LoginScreen()
var userType = login.checkPrivs()
+9

Swift 3

- , , - () :

var userType = LoginScreen().checkPrivs()

5/11/17 Xcode Swift.

+1

Source: https://habr.com/ru/post/1546124/


All Articles