来自webservice的解析百分比显示为数字

时间:2015-07-27 07:48:18

标签: ios

[offStr setString:[offStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSMutableURLRequest *offrequest = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:offStr]];
    NSLog(@"%@",offStr);
    [offrequest setHTTPMethod:@"POST"];
    _connection = [[NSURLConnection alloc]initWithRequest:offrequest delegate:self startImmediately:YES];

        NSURL *offurl = [NSURL URLWithString:offStr];
    NSData *offdata = [NSData dataWithContentsOfURL:offurl];
    NSDictionary *offjson = [NSJSONSerialization JSONObjectWithData:offdata options:kNilOptions error:nil];
    NSArray *offarr = [offjson objectForKey:@"Response"];
    NSMutableArray *offersArr = [[NSMutableArray alloc]init];
    NSDictionary* offers = [offarr objectAtIndex:0];
NSArray *offersInside = [offers objectForKey:@"0"];
    for (int i=0; i<offersInside.count; i++) {
        NSString *offerstr = [NSString stringWithFormat:[offersInside objectAtIndex:i]];
               NSLog(@"%@",offerstr);

       [offersArr addObject:offerstr];
        NSLog(@"%@",offersArr);

我在日志中收到以下内容:

  

256607337541FF关于钻石上的钻石和宝石珠宝订单。   金刚石和宝石珠宝订单25,000和306607337541FF   超过RS。 25,000但我的实际字符串是DIAMOND AND 25%折扣   RS上的宝石珠宝订单。 25000

1 个答案:

答案 0 :(得分:0)

试试这个

 NSMutableArray *offersArr = [[NSMutableArray alloc]init];

NSData *offdata = [NSData dataWithContentsOfURL:[NSURL URLWithString:offStr]];
NSArray *offersInside  = [[[[NSJSONSerialization JSONObjectWithData:offdata options:kNilOptions error:nil]objectForKey:@"Response"]objectAtIndex:0]objectForKey:@"0"];
[offerArr addObjectsfromArray: offersInside];