0

私はこのようなクラスを持っています:

@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

これらのクラスから次のような複雑なコレクションを作成します。

  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];

NSMutableArraylをjsonやxmlなどのポータブル形式にシリアル化したいもの。そうするコードを投稿していただけませんか?

心から

ゾリ

4

1 に答える 1

0

さらに調査した結果、自分のニーズに適したものは何も見つかりませんでした。JSONについてもう少し学び、JSON構造を手動で作成する関数を作成することにしました。たとえ2〜3時間かかったとしても、それはすべての努力の価値がありました。

于 2012-06-05T12:11:36.123 に答える