Coder Social home page Coder Social logo

cocoatreeviewexample's Introduction

======================= Cocoa Tree View Example

Author: Stefan Eletzhofer

Date: 2011-06-30

Version: 0.3.1

Abstract

For a project I'm currently at, I have the requirement to view heirachical data in one UITableView.

This is what I've come up with, it's a proof-of-concept and badly needs refactoring.

License

This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

Features

  • collapsable/expandable UITableViewCells
  • NSMutableDictionary as data model
  • no hacks

Data Model

All the specific tree/list handling stuff is done in TreeListModel. This class offers accessor methods which make it fairly simple to use it as a UITableViewDataSource.

Demo data is load from a JSON file which looks like this. You get the idea ;)

    {
        "key": "root", 
        "isOpen": true, 
        "value": [
            {
                "isOpen": true, 
                "key": "Chapter 1", 
                "value": [
                    {
                        "isOpen": false, 
                        "key": "Subchapter 1.1", 
                        "value": []
                    }, 
                    {
                        "isOpen": true, 
                        "key": "Subchapter 1.2", 
                        "value": [
                            {
                                "isOpen": false, 
                                "key": "Sub Sub Chapter 1.2.1", 
                                "value": []
                            }, 
                            {
                                "isOpen": false, 
                                "key": "Sub Sub Chapter 1.2.2", 
                                "value": []
                            }, 
                            {
                                "isOpen": false, 
                                "key": "Sub Sub Chapter 1.2.3", 
                                "value": []
                            }
                        ]
                    }, 
                    {
                        "isOpen": false, 
                        "key": "Subchapter 1.3", 
                        "value": []
                    }
                ]
            }, 
            {
                "isOpen": false, 
                "key": "Chapter 2", 
                "value": [
                    {
                        "isOpen": false, 
                        "key": "Subchapter 2.1", 
                        "value": []
                    }, 
                    {
                        "isOpen": false, 
                        "key": "Subchapter 2.2", 
                        "value": []
                    }, 
                    {
                        "isOpen": false, 
                        "key": "Subchapter 2.3", 
                        "value": []
                    }
                ]
            }, 
            {
                "isOpen": true, 
                "key": "Chapter 3", 
                "value": [
                    {
                        "isOpen": false, 
                        "key": "Subchapter 3.1", 
                        "value": []
                    }, 
                    {
                        "isOpen": false, 
                        "key": "Subchapter 3.2", 
                        "value": []
                    }, 
                    {
                        "isOpen": false, 
                        "key": "Subchapter 3.3", 
                        "value": []
                    }
                ]
            }
        ]
    }

Changelog

0.3.1 - 2011-06-30

  • update license

0.3 - 2011-05-10

  • added some custom UITableViewCells which fancy lines and stuff.
  • upgrade JSON data model to multivalued data.
  • made a universal app.
  • use KVC to access model items. Remove NSMutableDictionary dependency.

0.2 - 2011-05-09

  • refactored, created TreeListModel.

0.1 - 2011-05-06

  • Initial release to github

cocoatreeviewexample's People

Contributors

juandazapata avatar macbuildserver avatar seletz avatar vladignatyev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.