Plist to tableview

  • Newbie question:
    How does one import an array of values from a dictionary (plist) and display
    on a window?
    It seems that the plist has to be translated to XML data and every byte read
    into an array.
    How does one then select just certain members where the plist contains an
    array under a key?
    I am trying to get this list into a tableview but not sure how to populate
    the data.
    Any help is appreciated.
    Thanks, Richard.
  • On Wed, Nov 19, 2008 at 6:45 PM, Richard S. French <rsfrench...> wrote:
    > Newbie question:
    > How does one import an array of values from a dictionary (plist) and display
    > on a window?

    Deserialize the plist into an NSArray object.  Provide the values from
    the NSArray to an NSTableView using a data source, or bind the table
    view to an NSArrayController that's bound to the array.

    > It seems that the plist has to be translated to XML data and every byte read
    > into an array.

    Huh?  Read the Property List Programming Guide again:
    http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Pro
    pertyLists.html


    > How does one then select just certain members where the plist contains an
    > array under a key?

    Loop through the array that results from deserialization and choose
    only the entries you want.  Alternatively, use an NSPredicate.

    > I am trying to get this list into a tableview but not sure how to populate
    > the data.

    NSTableView has a -setDataSource: method that takes an object which
    conforms to the NSTableViewDataSource protocol.  Or you can use
    bindings (not recommended for a beginner).

    --Kyle Sluder
  • On Wed, Nov 19, 2008 at 9:27 PM, Richard S. French <rsfrench...> wrote:
    > How do I return a count and the data?

    Read up on implementing a table view data source.  Your data source
    object implements these methods and returns the correct data.  So once
    you have loaded the data from a plist and filtered it as necessary,
    return the number of items in the array from your implementation of
    -numberOfRowsInTableView:, and return the requested cell data from
    -tableView:objectValueForTableColumn:row:.

    --Kyle Sluder
previous month november 2008 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today
MindNode
MindNode offered a free license !