0

I have a classes looking like this:

@interface AISlideItem: NSObject <NSCoding>
{
    NSString*  PlaceHolderName;
    NSInteger PlaceHolderID;
}
@property (nonatomic, strong) NSString* PlaceHolderName;
@property (nonatomic) NSInteger PlaceHolderID;

@end

@interface AITitleSlideItem : AISlideItem
{
    NSString* Title;
}
@property (nonatomic, strong) NSString* Title;
@end

@interface AIParagraphSlideItem : AISlideItem
{
    NSMutableArray* Paragraphs;
}
@property (nonatomic, strong) NSMutableArray* Paragraphs;
@end

@interface AITextSlideItem : AISlideItem
{
    NSString* Text;
}
@property (nonatomic, strong) NSString* Text;
@end

@interface AIPictureSlideItem : AISlideItem
{
    NSMutableData* Picture;
}
@property (nonatomic, strong) NSMutableData* Picture;
@end

@interface AISlideContent : NSObject
{
    NSString*       LayoutName;
    NSMutableArray* Items;
}
@property (nonatomic,strong) NSString* LayoutName;
@property (nonatomic,strong) NSMutableArray* Items;
@end

@interface ContentParaghraph : NSObject
{
    NSInteger Level;
    NSString* Text;
}
@property (nonatomic) NSInteger Level;
@property (nonatomic, strong) NSString* Text;
@end

I create a complex collection from these classes like this:

  NSMutableArray* l = [[NSMutableArray alloc]init ];

        AITitleSlideItem* tis1 = [[AITitleSlideItem alloc]init];
        [tis1 setPlaceHolderName:@"I don't think we're using this..."];
        [tis1 setPlaceHolderID:1];
        [tis1 setTitle:@"This is a title"];

        AITextSlideItem* tes1 = [[AITextSlideItem alloc]init];
        [tes1 setPlaceHolderName:@"I don't think we're using this..."];
        [tes1 setPlaceHolderID:2];
        [tes1 setText:@"This is the description"];

        AISlideContent* slide1 = [[AISlideContent alloc]init];
        [slide1 setLayoutName:@"Title content"];
        [[slide1 Items]addObject:tis1];
        [[slide1 Items]addObject:tes1];


        [l addObject:slide1];
        [l addObject:slide1];

What i want to to serialize the NSMutableArray l into any portable format like json or xml. Could you please post some code doing so?

Sincerely

Zoli

Zoltan Varadi
  • 2,468
  • 2
  • 34
  • 51
  • repost of [Objective C serialize list of complex objects](http://stackoverflow.com/questions/10847865/objective-c-serialize-list-of-complex-objects) – vikingosegundo Jun 01 '12 at 15:44

1 Answers1

0

After further investigation i found nothing more suitable for my needs. I decided to learn a bit more about JSON and create a function that creates the JSON structure manually. Even if it took 2-3 hours, it did worth all the effort.

Zoltan Varadi
  • 2,468
  • 2
  • 34
  • 51