Xcode, Fold group of codes under certain method/ function with a simple click

57 views Asked by At

I Have a multiple if else statements under another if else statements and I want to be able to fold all child statements under certain parent without have to fold each one separately cause its like 100's of them. For Example (Just a generic code, it can be anything else):

the code Unfolded

func example(v1: String, v2: Int, v3: Int)
{
    if v1 == "Food"
    {
        if v2 == 2 && v3 == 7
        {
            // Some Long Lines Codes
        }
        else if v2 == 2 && v3 == 33
        {
            // Some Long Lines Codes
        }
        else if v2 == 44 && v3 == 72
        {
            // Some Long Lines Codes
        }
        else if v2 == 12 && v3 == 7
        {
            // Some Long Lines Codes
        }
        else if v2 == 102 && v3 == 97
        {
            // Some Long Lines Codes
        }
    }
}

And I Wanted To Be Folded Like That With A Simple Click Not Fold It One By One

func example(v1: String, v2: Int, v3: Int)
{
    if v1 == "Food"
    {
        if v2 == 2 && v3 == 7
        {...}
        else if v2 == 2 && v3 == 33
        {...}
        else if v2 == 44 && v3 == 72
        {...}
        else if v2 == 12 && v3 == 7
        {...}
        else if v2 == 102 && v3 == 97
        {...}
    }
}

Imaging like 100 lines of those else if conditions that i need to fold each one manually using CMD + Opt + <- or even using the arrow beside, I hope there is a fast and reliable shortcut or a click to help folding child codes or selected codes

btw I know there is a cmd + opt + shift + <- to fold all but that's not helping cause when I unfold the function I would see all remains as it was before.

I hope anyone could have a clue or if there is an ability to add a script function to do so.

0

There are 0 answers