PDA

View Full Version : NSTreeNode and NSCoder




i.yalovecky
Sep 2, 2010, 07:44 AM
Can i encode and decode my NSTreeNode tree with NSCoder?



robbieduncan
Sep 2, 2010, 07:46 AM
Have you tried?

i.yalovecky
Sep 2, 2010, 07:54 AM
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.

i.yalovecky
Sep 2, 2010, 07:56 AM
I read about NSCoder compliant, i need to subclass NSTreeNode or better convert it to source string?

robbieduncan
Sep 2, 2010, 07:58 AM
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.

i.yalovecky
Sep 2, 2010, 09:22 AM
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.

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.