我不能 post 我的字典值

I can't post my dictionary values

我不能 Post NSMutableDictionary Web 服务的值 Url

这是我的代码

 NSMutableArray*MatcRegistraionGetArray=[PushSyncDBMANAGER RetrieveMATCHREGISTRATIONData:_competitionCode :_matchCode];  NSMutableArray*MatchTeamplayerDetailsGetArray=[PushSyncDBMANAGER RetrieveMATCHTEAMPLAYERDETAILSData:_matchCode];

  NSMutableDictionary *PushDict =[[NSMutableDictionary alloc]init];
   [PushDict setValue :MatcRegistraionGetArray forKey:@"MatcRegistraion"];

    [PushDict setValue:MatchTeamplayerDetailsGetArray forKey:@"MatchTeamplayerDetails"];


 NSData *jsonData = [NSJSONSerialization dataWithJSONObject:PushDict options:kNilOptions error:nil];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSLog(@"JSON String: %@",jsonString);

    NSData* responseData = nil;
    NSString *urlString = @"http://192.168.1.39:8096/CAPMobilityService.svc/PUSHDATATOSERVER";
    NSURL *url=[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    responseData = [NSMutableData data] ;
    NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
    NSString *bodydata=[NSString stringWithFormat:@"%@",PushDict];

    [request setHTTPMethod:@"POST"];
    NSData *req=[NSData dataWithBytes:[bodydata UTF8String] length:[bodydata length]];
    [request setHTTPBody:req];
    NSURLResponse* response;
    NSError* error = nil;
    responseData = [NSURLConnection sendSynchronousRequest:request     returningResponse:&response error:&error];
    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

    NSLog(@"the final output is:%@",responseString);

但是我遇到了 CAPScoringApp[1261:39009] 的崩溃 *** 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因:'Invalid type in JSON write (InningsEventPushRecord)'

+(NSMutableArray *)RetrieveMATCHREGISTRATIONData: (NSString *) COMPETITIONCODE :(NSString *) MATCHCODE{
    NSMutableArray *MATCHREGISTRATIONArray=[[NSMutableArray alloc]init];
    int retVal;
    NSString *dbPath = [self getDBPath];
    sqlite3 *dataBase;
    const char *stmt;
    sqlite3_stmt *statement;
    retVal=sqlite3_open([dbPath UTF8String], &dataBase);
    if(retVal ==0){
        //(CASE WHEN MR.TEAMACODE='%@' THEN MR.TEAMBCODE ELSE MR.TEAMACODE END)
        NSString *query=[NSString stringWithFormat:@"SELECT * FROM MATCHREGISTRATION  WHERE COMPETITIONCODE='%@' AND MATCHCODE='%@'", COMPETITIONCODE,MATCHCODE];
        NSLog(@"%@",query);
        stmt=[query UTF8String];
        if(sqlite3_prepare(dataBase, stmt, -1, &statement, NULL)==SQLITE_OK)
        {
            while(sqlite3_step(statement)==SQLITE_ROW){
                NSLog(@"Success");

                InningsEventPushRecord *record=[[InningsEventPushRecord alloc]init];

                NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
                f.numberStyle = NSNumberFormatterDecimalStyle;
               // [f numberFromString:

                record.MATCHCODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)];
                record.MATCHNAME=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)];
                record. COMPETITIONCODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)];
                record. MATCHOVERS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 3)];
                record. MATCHOVERCOMMENTS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 4)];
                record. MATCHDATE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 5)];
                record. ISDAYNIGHT=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 6)];
                record. ISNEUTRALVENUE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 7)];
                record.  GROUNDCODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 8)];
                record.  TEAMACODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 9)];
                record.  TEAMBCODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 10)];
                record.  TEAMACAPTAIN=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 11)];
                record.  TEAMAWICKETKEEPER=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 12)];
                record. TEAMBCAPTAIN=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 13)];
                record. TEAMBWICKETKEEPER=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 14)];
                record.  UMPIRE1CODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 15)];
                record.  UMPIRE2CODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 16)];
                record.  UMPIRE3CODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 17)];
                record.   MATCHREFEREECODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 18)];
                //record.  VIDEOLOCATION=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 19)];
                record.   MATCHRESULT=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 20)];
                record.   MATCHRESULTTEAMCODE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 21)];
                record.   TEAMAPOINTS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 22)];
                record.   TEAMBPOINTS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 23)];
                record.   MATCHSTATUS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 24)];
                record.  RECORDSTATUS=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 25)];
                record.  CREATEDBY=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 26)];
                record. CREATEDDATE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 27)];
                record. MODIFIEDBY=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 28)];
                record. MODIFIEDDATE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 29)];
                record.ISDEFAULTORLASTINSTANCE=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 30)];

                record.ISSYNC=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 32)];

                [MATCHREGISTRATIONArray addObject:record];



            }
        }
        sqlite3_finalize(statement);
        sqlite3_close(dataBase);
    }
    return MATCHREGISTRATIONArray;
}

从 Dbmanager 我得到了 NsmutableArray,然后我将可变数组值添加到 NsMutableDictioanary 中,我通过了 Post PushDict,但是得到了 crash.Anyone 帮助我解决了这个问题

将此添加到 NSObjcet Class

  -(NSDictionary *)MatchRegistrationPushRecordDictionary {
return [NSDictionary dictionaryWithObjectsAndKeys:MATCHCODE,@"MATCHCODE",MATCHNAME,@"MATCHNAME", COMPETITIONCODE,@"COMPETITIONCODE",MATCHOVERS,@"MATCHOVERS", MATCHOVERCOMMENTS,@"MATCHOVERCOMMENTS", MATCHDATE,@"MATCHDATE",ISDAYNIGHT,@"ISDAYNIGHT",ISNEUTRALVENUE,@"ISNEUTRALVENUE", GROUNDCODE,@"GROUNDCODE",TEAMACODE,@"TEAMACODE", TEAMBCODE,@"TEAMBCODE", TEAMACAPTAIN,@"TEAMACAPTAIN",TEAMAWICKETKEEPER,@"TEAMAWICKETKEEPER", TEAMBCAPTAIN,@"TEAMBCAPTAIN", TEAMBWICKETKEEPER,@"TEAMBWICKETKEEPER", UMPIRE1CODE,@"UMPIRE1CODE", UMPIRE2CODE,@"UMPIRE2CODE", UMPIRE3CODE,@"UMPIRE3CODE", nil];
}  

和return在dbmanager中调用这个字典class