使用ASIHTTPRequest将json数据发布到Web服务时遇到错误

时间:2013-07-02 03:16:37

标签: objective-c json web-services asihttprequest

我遇到此错误消息: “ - [ASIFormDataRequest initWithURL:]:无法识别的选择器发送到实例0x93b4800 2013-07-02 11:07:25.603 DesignTable [1593:c07] * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [ASIFormDataRequest initWithURL:]:无法识别的选择器发送到实例0x93b4800 '“

-(void)sendBtnClicked:(UIButton*)sendBtn
{

for (int i = 0; i <tableArray.count; i++){

    NSMutableDictionary *tableLocation = [NSMutableDictionary dictionaryWithObjectsAndKeys:[tableYcoord objectAtIndex:i], @"yCoord" ,[tableXcoord objectAtIndex:i],@"xCoord", nil];
    [tableLocation setObject:[tableNameArr objectAtIndex:i] forKey:@"tableName"];
    [tableLocation setObject:[tableIDArray objectAtIndex:i] forKey:@"tableID"];
    [tableLocation setObject:[capacityArray objectAtIndex:i] forKey:@"capacity"];


    [tableAttributes addObject:tableLocation];

    //NSMutableDictionary *tableData = [NSMutableDictionary dictionaryWithObjectsAndKeys:tableLocation,@"tableLocation", nil];

    NSMutableDictionary *finalDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:tableAttributes,@"table", nil];



    NSError *error;
    jsonData = [NSJSONSerialization dataWithJSONObject:finalDictionary
                                                       options:NSJSONWritingPrettyPrinted
                                                         error:&error];



    aStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];





}

url  = [NSURL URLWithString:@"http://localhost/srvs/possrv/uploadTableDesign"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];

[request setValue:@"38" forKey:@"RestaurantID"];
[request setPostValue:jsonData forKey:@"json_data"];
[request startAsynchronous];

NSLog(@"%@", aStr);
sendBtn.enabled = NO;
}

这是我将json数据发送到我的webservice的代码。

0 个答案:

没有答案