2

I want to use alias defined in the Class1 class . I want to use it into Class2

import UIKit

class Class1: NSObject {
    typealias tp = () -> Void 


}


import UIKit

class Class2: NSObject {    
    func pingTest(){
        var test:tp?
    }
}

Class2 throws compile time error at var test:tp?

Also, the autocompletion does not work. Screen the shot attached with this email. I tried the following thing but that didn't work for me (XCode 6 isn't autocompleting in swift).

enter image description here

Community
  • 1
  • 1
NNikN
  • 3,720
  • 6
  • 44
  • 86

1 Answers1

5

You need to define the TypeAlias as public and that too outside the class.

The other option is to define protocol and inherit to any class.

Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57