下面2段代码是 JsonModel对象:
#import <JSONModel/JSONModel.h> @protocol PersonalInfoR @end @interface PersonalInfoR : JSONModel @property NSInteger id; @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *phone; @property NSInteger birthday; @property NSInteger mainAddressId; @property NSInteger mainCompanyId; @property (nonatomic, copy) NSString *picAddr; @property NSInteger termId; @property (nonatomic, copy) NSString *password; @property NSInteger valid; @property NSInteger loginTime; @property NSInteger privacy; @property (nonatomic, copy) NSString *pinyin; @property NSInteger onlinetime; @end
@protocol PersonalInfoR; @interface PersonalInfo : JSONModel @property (nonatomic, strong) PersonalInfoR *body; @property NSInteger status; @property (nonatomic, copy) NSString *message; @end
使用
_myPersonalInfo = [[PersonalInfo alloc] initWithDictionary:responseObject error:nil];
获取http请求返回到数据,responseObject 是返回数据。
直接输出 responseObject 如下:
有数据, 但_myPersonalInfo 为空:如下
搞了好久,还没解决,请高手赐教
解决方案
20
建议改为 _myPersonalInfo = [[PersonalInfo alloc] initWithDictionary:[responseObject objectForKey:@”body”] error:nil]; 试试