Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve the program crash issue #4

Open
SinCheung opened this issue Oct 21, 2014 · 0 comments
Open

Solve the program crash issue #4

SinCheung opened this issue Oct 21, 2014 · 0 comments

Comments

@SinCheung
Copy link

//recursively add children and all its expanded children to array at position index

  • (int) _insertChildren:(NSArray *)children inArray:(NSMutableArray *)array atIndex:(NSUInteger)index{

    [array replaceObjectsInRange:NSMakeRange(index, 0) withObjectsFromArray:children];
    int res = 0;
    int i=0;
    res += children.count;//start set the children count,then through recursive function to calculate the real child node`s children count.

    for (GITreeNode *child in children) {
    if (child.directoryIsExpanded) {
    //here set a var to save the return value of recursive function.
    int count= [self _insertChildren:child.children inArray:array atIndex:index+i+1];
    i += count;
    res += count;//add return value of recursive function,to solve the crash
    // res += child.children.count;
    }
    i++;
    }
    return res;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant