【问题标题】:How to post parameter like ' \u0001[xxxx] ' using AFNetworking如何使用 AFNetworking 发布类似“\u0001[xxxx]”的参数
【发布时间】:2016-01-03 11:59:05
【问题描述】:

我做了这个,但是错误 [NSString stringWithFormat:@"%@", @"\u0001[xxxx]"]

    NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:
                            [NSString stringWithFormat:@"%@", @"\u0001[xxxx]"], @"content",
                            [NSNumber numberWithBool:anonymous],@"aaaaa",
                            nil];

return [manager POST:submitCommentUrlString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject){
    ...

} failure:^(AFHTTPRequestOperation *operation, NSError *error){
    ...
}];

【问题讨论】:

    标签: objective-c xcode post http-post afnetworking


    【解决方案1】:

    尝试使用

    [[NSString stringWithFormat:@"%@", @"\u0001[xxxx]"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

    而不是

    [NSString stringWithFormat:@"%@", @"\u0001[xxxx]"]
    

    为了在字典中设置对象。

    【讨论】:

    • 谢谢,我会试试这个。但我发现 [NSString stringWithFormat:@"%C", 0x1] == \u0001
    【解决方案2】:
    [NSString stringWithFormat:@"%C", 0x1]
    

    这是\u0001

    【讨论】:

      猜你喜欢
      • 2016-03-29
      • 1970-01-01
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多