我有两个班级
=== PEOPLE ====
@protocol People @end
@interface People : JSONModel
@property (strong, nonatomic) NSString *id;
@property (strong, nonatomic) NSString *userName;
@end
=== PEOPLE CONTAINER ====
@interface PeopleContainer : JSONModel
@property (strong, nonatomic) People *people;
@end
代码在此行失败:
PeopleContainer *peopleContainer = [[PeopleContainer alloc] initWithDictionary:peopleContainerDict error:&err];
给出错误:
*** Terminating app due to uncaught exception 'Type not allowed', reason: 'Account type not supported for ChatRoomContainer.account'
*** First throw call stack: (0x2243012 0x1725e7e 0x34e90 0x76ef5 0xf18cf8 0xe8075a 0xe4e453 0xe4e164 0xedaa31 0x50fe53f 0x5110014 0x51012e8 0x5101450 0x53d9e72 0x53c1daa) libc++abi.dylib: terminate called throwing an exception
问题是它在iOS> 7下完全正常,但在iOS 6.1上却没有 (我已在模拟器和设备上测试过它。)
有人可以帮忙吗?
编辑:
这是ACCOUNT CLASS
#import <Foundation/Foundation.h>
#import "JSONModel.h"
@protocol Account @end
@interface Account : JSONModel
@property (strong, nonatomic) NSString *id;
@property (strong, nonatomic) NSString *userName;
@property (strong, nonatomic) NSString *emailAddress;
@property (strong, nonatomic) NSString *password;
@property (strong, nonatomic) NSString *phoneNumber;
@end
包含ACCOUNT CLASS的另一类CHAT ROOM CONTAINER
#import "JSONModel.h"
#import "Account.h"
#import "Friend.h"
#import "ChatRoom.h"
@interface ChatRoomContainer : JSONModel
@property (strong, nonatomic) Account *account;
@property (strong, nonatomic) NSArray<ChatRoom> *chatRooms;
@property (strong, nonatomic) NSArray<Friend> *friends;
@end
我使用
向我们的服务器发送请求[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:
^(NSURLResponse *response, NSData *data, NSError *error)
{
if (completion) {
if (!error) {
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSDictionary *errorDict = [responseDict objectForKey:@"error"];
NSDictionary *warningDict = [responseDict objectForKey:@"warning"];
NSDictionary *result = [responseDict objectForKey:@"result"];
NSLog(@"RESULT\n====\n%@\n====\n",responseDict);
if(errorDict != nil && ![[NSNull null] isEqual:errorDict]) {
NSError* err = nil;
CustomError *error = [[CustomError alloc] initWithDictionary:errorDict error:&err];
completion(NO, nil, error, nil);
} else {
NSDictionary *chatRoomContainerDict = [result objectForKey:@"chatRoomContainer"];
NSError* err = nil;
ChatRoomContainer *chatRoomContainer = [[ChatRoomContainer alloc] initWithDictionary:chatRoomContainerDict error:&err];
if(!err) {
CustomWarning *warning = [[CustomWarning alloc] initWithDictionary:warningDict error:&err];
completion(!error, chatRoomContainer, nil, warning);
} else {
NSLog(@"ERROR WHILE PARSING CHAT ROOM CONTAINER JSON DICT!!! %@", [err userInfo]);
completion(!error, nil, nil, nil);
}
}
} else {
if(![AuxiliaryHelper connectedToInternet]) {
NSLog(@"NO INTERNET CONNECTION");
completion(NO, nil, [[CustomError alloc] initWithErrorType:ErrorTypeNoInternetConnection], nil);
} else {
DLog(@"INTERNAL SERVER ERROR!!!");
completion(NO, nil, [[CustomError alloc] initWithErrorType:ErrorTypeInternalServerError], nil);
}
}
}
}];
答案 0 :(得分:0)
我也遇到过这个问题。也许错误来自您的班级“帐户,聊天室等”。
我写
objc
@property (assign,nonatomic) NSInteger goodId;
到
objc
@property (assign,nonatomic) NSInteger* goodId;
所以只需检查U类