0

私は2つのクラスを持っています

=== 人々 ====

@protocol People @end

@interface People : JSONModel

@property (strong, nonatomic) NSString      *id;
@property (strong, nonatomic) NSString      *userName;

@end

===ピープルコンテナ====

@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 では動作しないことです (シミュレーターとデバイスの両方でテストしました)。

誰か助けてくれませんか?

編集:

アカウントクラスはこちら

#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);
             }
         }
     }
 }];
4

1 に答える 1

0

私もこの問題に遭遇します。おそらく、クラス「アカウント、チャットルームなど」からエラーが発生した可能性があります。私は書い objc @property (assign,nonatomic) NSInteger goodId; objc @property (assign,nonatomic) NSInteger* goodId; ので、Uクラスをチェックしてください

于 2016-07-25T07:53:34.947 に答える