Augustyniak / RATreeView

Library providing easy-to-use interface for displaying tree structures on iOS and tvOS.
MIT License
2.49k stars 465 forks source link

child:ofItem bug in swift #83

Closed aisk closed 8 years ago

aisk commented 9 years ago

Hi, I use RATreeView in swift, and found a bug:

func treeView(treeView: RATreeView!, child index: Int, ofItem item: AnyObject!) -> AnyObject! {
    if item == nil {
        return sportTypes![index]
    }
    let sportType = item as SportType
    return sportType.subSportTypes![index]
}

This will return the root SportTypes at first level cells. When I click a cell, this function is called and I think the item will be not nil but the parent item, and I can choose child item to return. But actually the item is still nil. Now I saved the item in didSelectRowForItem, and use this to choose if a child item is clicked for workaround.

TechGuyVN commented 9 years ago

can your share your porting code to swift, i can port with no error but title of each cell not display, i have no idea why ?

Augustyniak commented 8 years ago

@aisk Sorry that you have to wait for a response so much time. I created an example project in Swift and everything seems to work OK - maybe it was fixed in the newest releases of the application.

@TechGuyVN I added an example project which is entirely written in Swift. It can be found at https://github.com/Augustyniak/RATreeView/tree/master/Examples. Just run example project and select RATreeViewBasicExampleSwift target to run it.

I attached the screenshot that shows how you can change select a target within Xcode project.

napkin 28-11-15 3 18 06 pm

I hope that this helps.

aisk commented 8 years ago

@Augustyniak Thanks for resolve it, and sadly this issue lives longer than my project 😂