Problems loading data into NSTableView using a NSArrayController

  • Hi

    I am using NSArrayController to load two columns of a table View and the method I am using is:

    NSArrayController *tableViewController_;

    - (void)loadArrayController {

    // kPlistPath is the path to the plist file I am using. It has 100 Key-Value Pairs
      NSDictionary *plistDictionary = [NSDictionary dictionaryWithContentsOfFile:kPlistPath];

      NSMutableDictionary *newDictionary = [NSMutableDictionary dictionary];

      [newDictionary setValue:[plistDictionary allKeys] forKey:@"Methods"];

      [newDictionary setValue:[plistDictionary allValues] forKey:@"Address"];

      [tableViewController_ addObject:newDictionary];

    }

    I have till now managed to get a braket in each column.
    What am I doing wrong? or how else should I do
    this?

    Thank you
    DG

          Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
  • On Sep 25, 2007, at 7:02 PM, deepak gopal wrote:

    > Hi
    >
    > I am using NSArrayController to load two columns of a table View
    > and the method I am using is:
    >
    > NSArrayController *tableViewController_;
    >
    > - (void)loadArrayController {
    >
    > // kPlistPath is the path to the plist file I am using. It has 100
    > Key-Value Pairs
    > NSDictionary *plistDictionary = [NSDictionary
    > dictionaryWithContentsOfFile:kPlistPath];
    >
    > NSMutableDictionary *newDictionary = [NSMutableDictionary
    > dictionary];
    >
    > [newDictionary setValue:[plistDictionary allKeys]
    > forKey:@"Methods"];
    >
    > [newDictionary setValue:[plistDictionary allValues]
    > forKey:@"Address"];
    >
    > [tableViewController_ addObject:newDictionary];
    >
    > }
    >
    > I have till now managed to get a braket in each column.
    > What am I doing wrong?

    NSArrayControllers work on arrays not on dictionaries. Likely want
    you want to do is create an array of dictionaries with each
    dictionary having a "Method" key with related value (a single value)
    and an "Address" key with related value (a single value). Then set
    that dictionary as the content of array controller.

    > or how else should I do this?

    I suggest you not try to use the controller layer stuff just yet. You
    can easily does this using a data source and the data structure I
    outlined.

    -Shawn
previous month september 2007 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