Elye
Elye

Reputation: 60341

Shortcut to Fold all function ⌘ ⌥ ⇧ ← no longer work in Xcode 10.1?

As shared by https://stackoverflow.com/a/46020397/3286489, the shortcut ⌘ ⌥ ⇧ ← can be used to FOLD all the functions. However, when I tried on my Xcode 10.1, it can't work.

⌘ ⌥ ← works (fold one function).

Is this default shortcut removed in Xcode 10.1?

Upvotes: 1

Views: 73

Answers (1)

Elye
Elye

Reputation: 60341

Apparently, ⌘ ⌥ ⇧ ← only works on functions collapse. If there's no functions in the code, then nothing is seen. But ⌘ ⌥ ← works on class, enum etc.

E.g. the below code don't see any effect using ⌘ ⌥ ⇧ ←

extension UIColor {
  open class var brightRedColor: UIColor {
    return UIColor(red: 255.0/255.0, green: 59.0/255.0, blue: 48.0/255.0, alpha: 1.0)
  }
  open class var brightGreenColor: UIColor {
    return UIColor(red: 76.0/255.0, green: 217.0/255.0, blue: 100.0/255.0, alpha: 1.0)
  }
  open class var brightBlueColor: UIColor {
    return UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)
  }
}

But the below does see effect (including the class func) after pressing ⌘ ⌥ ⇧ ←

class BugFactory {

    // MARK: Properties

    static let bugTints: [UIColor] = [.black, .brightBlueColor, .brightRedColor, .brightGreenColor]
    static let shakeRotations = [Double.pi/16, Double.pi/8, Double.pi/8, Double.pi/24]
    static let shakeDurations = [0.3, 3.0, 0.1, 0.5]
    static let bugSize = CGSize(width: 128, height: 128)

    enum BugType: Int {
        case basic, slow, fast, smooth
    }

    var currentBugType = BugType.basic

    // MARK: Create Bug

    func createBug() -> UIImageView {
        let bug = UIImageView(frame: CGRect(x: -100, y: -100, width: 128, height: 128))
        bug.image = UIImage(named: "spider")
        bug.tintColor = BugFactory.bugTints[currentBugType.rawValue]

        // add simple "shake" key-frame animation
        // for explanation, see http://www.objc.io/issue-12/animations-explained.html
        let shakeAnimation = CABasicAnimation(keyPath: "transform.rotation")
        shakeAnimation.toValue = 0.0
        shakeAnimation.fromValue = BugFactory.shakeRotations[currentBugType.rawValue]
        shakeAnimation.duration = BugFactory.shakeDurations[currentBugType.rawValue]
        shakeAnimation.repeatCount = Float.infinity
        shakeAnimation.autoreverses = true
        shakeAnimation.isRemovedOnCompletion = false
        bug.layer.add(shakeAnimation, forKey: "shake")

        return bug
    }

    // MARK: Shared Instance

    class func sharedInstance() -> BugFactory {

        struct Singleton {
            static var sharedInstance = BugFactory()
        }

        return Singleton.sharedInstance
    }
}

Upvotes: 1

Related Questions