Nat! bio photo

Nat!

Senior Mull

Twitter Github Twitch

Foundation Curiosity: NSSet as a property list

Why is it, that you can print NSSet as a property list, but you can't parse it ?

main.m
//  Coded by Nat! on 4.11.10, Mulle KybernetiK
#import <Foundation/Foundation.h>


int   main( int argc, char **argv) 
{
   NSAutoreleasePool      *pool;
   NSString               *s;
   NSSet                  *set;
   NSData                 *data;
   NSPropertyListFormat   format;
   id                     plist;   

   pool  = [NSAutoreleasePool new];
   
   set   = [NSSet setWithObjects:@"VfL", @"Bochum", @"1848", nil];
   s     = [set description];
   data  = [s dataUsingEncoding:NSUTF8StringEncoding];
   plist = [NSPropertyListSerialization 
                   propertyListFromData:data
                       mutabilityOption:NSPropertyListImmutable
                                 format:&format 
                       errorDescription:NULL];

   NSLog( @"plist %@ could %sbe parsed.", set, [plist isEqual:set] ? "" : "NOT ");

   [pool release];
   return( 0);
}
[Switching to process 48017]
Running…
2010-11-04 21:21:25.906 SetAsPlist[48017:a0f] plist {(
    VfL,
    Bochum,
    1848
)} could NOT be parsed.

Post a comment

All comments are held for moderation; basic HTML formatting accepted.

Name:
E-mail: (not published)
Website: