我正在解析 json 并且 url 返回一个整数值。(例如 278)
-(void) connectionDidFinishLoading: (NSURLConnection *) connection{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSString *responseString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"JSON Response = %@",responseString);}
当我在 NSLog 中打印响应时,它会给出类似这样的内容
2012-09-15 18:02:02.091 Web Service[5190:f803] JSON Response = "278"
我不想要引号中的输出。我想要它喜欢
2012-09-15 18:02:02.091 Web Service[5190:f803] JSON Response = 278
我怎样才能做到这一点?
JSON
NSString *urlString = [NSString stringWithFormat:@"http://10.5.6.105/ARAPPWS/Service1/InsertEmp/name=%@,phone=%@",name.text,number.text];
NSURL *addUrl = [NSURL URLWithString:urlString];
NSURLRequest *addRequest = [NSURLRequest requestWithURL:addUrl];
(void)[NSURLConnection connectionWithRequest:addRequest delegate:self];
-(void) connection: (NSURLConnection *) connection didReceiveResponse:(NSURLResponse *)response
{
jsonData = [[NSMutableData alloc]init];
}
-(void) connection: (NSURLConnection *) connection didReceiveData:(NSData *)data
{
[jsonData appendData:data];
}
-(void) connectionDidFinishLoading: (NSURLConnection *) connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
responseString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[self performSelector:@selector(uploadEmpImg:) withObject:nil afterDelay:1];
}
提前致谢。