I found a question most similar to mine however it was not thoroughly answered. It would be great if anyone could help me out. The place where I found the similar question is here.
I understand clearly how func test()
would be "test"
and test(object:AnyObject)
would be "test:"
. Thanks to this.
So how about 2 parameters? Can swift not do 2 arguments for 'action:'?
func popoverSelectedCode (code:AnyObject, desc:AnyObject)
I tried testing it out in few different ways below, but to no avail:
action: "popoverSelectedCode:,"
action: "popoverSelectedCode:,:"
action: "popoverSelectedCode: :"
action: "popoverSelectedCode: , :"
Am only about a week's old in Swift so please be kind.
EDITED Here is a short clip of the code
@IBAction func securityQuestButtonClicked (sender:AnyObject)
{
cellButton = sender as? UIButton;
var comboDescListArray = TableRoutine.loadCombobox("MobileQuestion")
var codeObject : NSArray = comboDescListArray[0] as NSArray;
var descObject : NSArray = comboDescListArray[1] as NSArray;
var selectionTVC = CPSelectionTVC(style:UITableViewStyle.Plain, codeArray:codeObject, descArray:descObject, target:self, action: "popoverSelectedCode::", widthForViewInPopover:650)
let navCtl = UINavigationController.init(rootViewController:selectionTVC)
popoverController = UIPopoverController.init(contentViewController:navCtl)
var contentHeight : CGFloat = CGFloat (UInt(selectionTVC.navigationTitleHeight) + UInt(selectionTVC.rowCount()) * UInt(selectionTVC.cellHeight))
popoverController?.popoverContentSize = CGSizeMake(400.0, contentHeight)
popoverController?.presentPopoverFromRect(sender.bounds, inView:sender as UIView, permittedArrowDirections:UIPopoverArrowDirection.Up, animated:true)
}
The popover appears however upon selecting, it just hangs.
Just a note on Swift 2.2. You can now type the selector as
#selector(popoverSelectedCode(_:desc:)
check this below code
func switchCard(card: Int, withCard card1: Int) {
print(card)
}
let singleTap1 = UITapGestureRecognizer(target: self, action: "switchCard:withCard:")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With