如何使用RestKit发出同步请求?
我之前用过这种方式(SBJSON):
UIDevice *myDevice = [UIDevice currentDevice];
NSString *deviceUDID = [myDevice uniqueIdentifier];
double v = [[[UIDevice currentDevice] systemVersion]doubleValue];
NSString *version=[NSString stringWithFormat:@"%@ %.1f",deviceType,v];
NSString *encodedParam1 =[version stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *requestString = [NSString stringWithFormat:@"method=views.get&view_name=client_list",nil];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *urlString = [NSString stringWithFormat:@"http://localhost/index.php?oper=StoreDeviceId&device_id=%@&device_version=%@",deviceUDID,encodedParam1];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod: @"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody: requestData];
//Data returned by WebService
NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];
[request release];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];
NSDictionary *dict1 = [returnString JSONValue];
同样的操作如何使用 restkit 框架来处理。
提前谢谢