0

我对这个库和我的对象有一些问题,我有 3 种对象:页面、小部件、画廊

page:
int
string
dictionary of widget

widget:
int
string 
dictionary gallery

gallery
int
string
array page

我创建了所有协议,所以我创建了类似的东西:

        page:
        import widget
        int
        string
        dict<Widget>

        widget
        import gallery
        int
        string
        Gallery
        dict<Gallery>

        Gallery
        import page
        int
        string
        array<Page>

在我创建委托和所有这些之后,我得到“未知类型”错误并且找不到协议......错误在哪里?

4

1 回答 1

0

需要定义协议并导入头文件

//Page.h
@protocol Page
@end

@class Widget;

@interface Page : JSONModel

@property (nonatomic, assign) NSInteger pageID;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) Widget *widget;

//Widget.h
@class Gallery;

@interface Widget : JSONModel

@property (nonatomic, assign) NSInteger widgetID;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) Gallery *gallery;

//Gallery.h
#import "Page.h"

@interface Gallery : JSONModel

@property (nonatomic, assign) NSInteger galleryID;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSArray<Page>* pages;
于 2015-06-22T10:26:09.720 回答