17

I have a Swift class:

class MyTextField : NSObject, UITextFieldDelegate { 

    var myField: UITextField

    // no idea how to pass in my UITextField from Objective-C code
    init (x: UITextField) {
        myField = x;
    }
}

I have added a property (not shown) so I could set myField, and everything is working.

Would like to use the init function, if only the syntax were not a complete mystery. Any ideas?

Gerry
  • 1,031
  • 1
  • 14
  • 30

1 Answers1

17

Call it the same way you'd call an Obj-C initializer, so for your example, you'd call [[MyTextField alloc] initWithX:theTextField];.

NRitH
  • 13,441
  • 4
  • 41
  • 44