@IBAction func getNewPhotoAction(sender: AnyObject) {
println("getNewPhotoAction")
}
override func viewDidLoad() {
super.viewDidLoad()
self.getNewPhotoAction(sender: AnyObject) // Error
}
I just want to call the getNewPhotoAction
IBAction method in viewDidLoad
.
Which parameter to enter in this line -> self.getNewPhotoAction(?????)
?
I don't have any parameter. I just need to call.
I used in Objective-C style:
[self getNewPhotoAction:nil]
but I don't know Swift style.
The parameter sender
indicates who are calling the action method.
When calling from viewDidLoad
, just pass self
to it.
override func viewDidLoad() {
super.viewDidLoad()
getNewPhotoAction(self)
}
By the way, if the sender
parameter of the getNewPhotoAction
method wasn’t used, the parameter name can be omitted.
@IBAction func getNewPhotoAction(AnyObject) {
println("getNewPhotoAction")
}
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