Reputation: 1236
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?
Upvotes: 19
Views: 6589
Reputation: 13893
Call it the same way you'd call an Obj-C initializer, so for your example, you'd call [[MyTextField alloc] initWithX:theTextField];
.
Upvotes: 18