stringByAddingPercentEscapesUsingEncoding:《iOS9中禁用》

    NSString *inputTxt = [NSString stringWithFormat:@"汉字内容"];
    
    // 输入内容转urlencoding编码,但是下面的第一句代码在iOS9中不适用了,所以下用下面的第二句代码
    // NSString *input = [inputTxt stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *input = [inputTxt stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

你可能感兴趣的:(iOS)