twotoasters / TTAlertView

MIT License
82 stars 20 forks source link

Swift incompatibility #24

Open gholias opened 10 years ago

gholias commented 10 years ago

Im trying to use the TTAlertView in a Swift project.

The .h is imported in the ObjC Bridge file, but the xcode complains of a build time error when Im trying to use like this: let alert:TTAlertView = TTAlertView(title: "Oops", message: "Something is missing:\n" + errorMsg, delegate: nil, cancelButtonTitle: "OK", otherButtonTitles:nil)

The only way I can build is by removing the otherButtonTitles parameter let alert:TTAlertView = TTAlertView(title: "Oops", message: "Something is missing:\n" + errorMsg, delegate: nil, cancelButtonTitle: "OK")

but this causes a run time crash -[TTAlertView initWithTitle:message:delegate:cancelButtonTitle:]: unrecognized selector sent to instance 0x7fdffd2b7a20

Any ideias what is wrong?

jeremyellison commented 10 years ago

It looks like this is due to the use of variadic arguments in the constructor. I expect a minor refactor would fix this. Take a look at this S.O. answer, I think it describes the steps it would take to make this swift compatible: http://stackoverflow.com/questions/24195796/how-do-you-call-an-objective-c-variadic-method-from-swift