首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSONModel NSString问题

JSONModel NSString问题
EN

Stack Overflow用户
提问于 2016-02-18 12:06:06
回答 1查看 176关注 0票数 1

在我的应用程序中,我使用雅虎Api和get responce,我现在在这个应用程序中使用JSONModel,创建一个json JSONModel类。

Past_Match.h文件

代码语言:javascript
复制
#import <JSONModel/JSONModel.h>
@protocol squadModel @end
@interface squadModel : JSONModel
@property (assign, nonatomic) int i;
@property (strong, nonatomic) NSString *full;
@end


@interface logoModel : JSONModel
@property (strong, nonatomic) NSString *std;
@end



@protocol teamsModel @end
@interface teamsModel : JSONModel
@property (assign, nonatomic) int i;
@property (strong, nonatomic) NSString *fn;
@property (strong, nonatomic) NSString *sn;
@property (strong, nonatomic) logoModel *logo;
@property (strong, nonatomic) NSArray<squadModel> *squad;
@end

@interface aModel : JSONModel
@property (assign, nonatomic) int i;
@property (assign, nonatomic) int r;
@property (assign, nonatomic) int o;
@property (assign, nonatomic) int w;
@property (assign, nonatomic) int cr;
@end


@interface sModel : JSONModel
@property (strong, nonatomic) aModel *a;
@end

@protocol tModel @end
@interface tModel : JSONModel
@property (assign, nonatomic) int i;
@property (assign, nonatomic) int a;
//@property (strong, nonatomic) NSString *c;
//@property (strong, nonatomic) NSString *dt;
@property (assign, nonatomic) int fd;
@property (assign, nonatomic) int bd;
//@property (strong, nonatomic) NSString *cb;
@property (assign, nonatomic) int b;
@property (assign, nonatomic) int r;
@property (assign, nonatomic) int sr;
@property (assign, nonatomic) int six;
@property (assign, nonatomic) int four;

@end


@interface anewModel : JSONModel
@property (strong, nonatomic) NSArray<tModel> *t;
@end


@interface dModel : JSONModel
@property (strong, nonatomic) anewModel *a;
@end


@protocol past_ingsModel @end
@interface past_ingsModel : JSONModel
@property (strong, nonatomic) sModel *s;
@property (strong, nonatomic) dModel *d;
@end


@interface ScorecardModel : JSONModel
@property (strong, nonatomic) NSString *mid;
@property (strong, nonatomic) NSArray<teamsModel> *teams;
@property (strong, nonatomic) NSArray<past_ingsModel> *past_ings;

@end

@interface resultsModel : JSONModel
@property (strong, nonatomic) ScorecardModel *Scorecard;

@end


@interface queryModel : JSONModel
@property (strong, nonatomic) resultsModel *results;

@end


@interface Past_Match : JSONModel
@property (strong, nonatomic) queryModel *query;
@end

Past_Match.m文件

代码语言:javascript
复制
#import "Past_Match.h"


@implementation squadModel
@end

@implementation logoModel
@end

@implementation teamsModel
@end

@implementation aModel
@end

@implementation sModel
@end

@implementation tModel
@end

@implementation anewModel
@end

@implementation dModel
@end

@implementation past_ingsModel
@end

@implementation ScorecardModel
@end

@implementation resultsModel
@end

@implementation queryModel
@end

@implementation Past_Match
@end

tModel中,如果我删除//并尝试获取NSString of cdtcd对象,则会遇到问题。所有3个NSString都有一个相同的问题,我无法得到这个值。其他所有的价值都在得到。我漏掉了什么?提前谢谢..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-18 12:12:17

此错误可能是由于您的响应对象中的可选值而发生的,请尝试以下.可能会起作用

代码语言:javascript
复制
@property (strong, nonatomic)NSString<Optional> *c;
@property (strong, nonatomic) NSString<Optional> *dt;
@property (strong, nonatomic) NSString<Optional> *cb;

提示:请将所有属性设置为可选

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35481044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档