AFNetworking请求中含有中文时程序崩溃

AFNetworking请求中含有中文时程序崩溃

    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    [manager GET:urlString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        //
    }];

 

出现error:

Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]

 

需要处理urlString的编码

urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

posted @ 2014-08-19 15:25  Rambot  阅读(1173)  评论(0编辑  收藏  举报