NSTreeNode and NSCoder

Discussion in 'Mac Programming' started by i.yalovecky, Sep 2, 2010.

  1. macrumors member

    Joined:
    Feb 24, 2010
    #1
    Can i encode and decode my NSTreeNode tree with NSCoder?
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
  3. thread starter macrumors member

    Joined:
    Feb 24, 2010
    #3
    I don't know how.

    The best way for me:
    [self.constantsView.rootTreeNode setObjectValue:[aDecoder decodeObject]];
    [aCoder encodeObject:[self.constantsView.rootTreeNode objectValue]];

    But nothing like objectValue there. I construct tree from plist, i can do reverse and after decoder and encode strings, but still hope for something easier way.
     
  4. thread starter macrumors member

    Joined:
    Feb 24, 2010
    #4
    I read about NSCoder compliant, i need to subclass NSTreeNode or better convert it to source string?
     
  5. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    The simple answer is that NSTreeNode does not confirm to NSCoding (as you could easily have seen by looking at the documentation). As such it cannot be encoded using a NSCoder.
     
  6. thread starter macrumors member

    Joined:
    Feb 24, 2010
    #6
    Ok, i convert my tree into plist NSString and encode it and decode it, but how now i can initialize NSDictionary with string? Because initially my tree initialized from plist through dictionary.

    i decide to convert my Tree into Dictionary firstly. So i dont need convertation from string to dictionary.
     

Share This Page