Is it possible to call one or another method depending a Bool
value? I wish to do this:
var isLocked: Bool
{
didSet
{
// This is not Swift but indicates what I'm looking for.
self.activityIndicator.(isLocked ? startAnimating() : stopAnimating())
}
}
I'm looking to do this using existing Swift 2 (or 3) language features; without class extensions.
Possibly a duplicate, but couldn't find.
How about:
didSet {
isLocked ? self.activityIndicator.startAnimating() :
self.activityIndicator.stopAnimating()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.