阿拉伯数据显示?????使用afnetworking库将asp.net mvc中的字符转换为ios应用 [英] Arabic data is showing ????? characters from asp.net mvc to ios app using afnetworking library

查看:63
本文介绍了阿拉伯数据显示?????使用afnetworking库将asp.net mvc中的字符转换为ios应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阿拉伯数据显示??????使用afnetworking库处理从asp.net mvc到ios应用的字符,以处理响应对象.

Arabic data is showing ????? characters from asp.net mvc to ios app using afnetworking library to handle the response object.

#import "AppGateway.h"

//the web location of the service
#define kAPIHost @"domain"
#define kAPIPath @"Home/GetNews/"

@implementation AppGateway

/*Singleton*/
+(AppGateway*)sharedInstance
{
    static AppGateway *sharedInstance = nil;
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        sharedInstance = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAPIHost]];
    });
    return sharedInstance;
}
-(AppGateway*)init{
    self = [super init];
    if(self!=nil) {
        [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
        [self setDefaultHeader:@"Accept" value:@"application/json"];
    }
    return self;
}

-(void)commandWithParams:(NSMutableDictionary *)params onCompletion:(JSONResponseBlock)completionBlock{
    NSMutableURLRequest *apiRequest = [self multipartFormRequestWithMethod:@"POST"
                                                                      path:kAPIPath
                                                                parameters:params
                                                 constructingBodyWithBlock:^(id <AFMultipartFormData>formData){
    }];
    AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:apiRequest];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
        NSLog(@"AFNTSUCCESS");
        //This is where response object carry arabic data corrupted to '??????????'
        completionBlock(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"AFNTFAILURE");
        completionBlock([NSDictionary dictionaryWithObject:[error localizedDescription] forKey:@"error"]);
    }];
    [operation start];
}

@end

这是我正在使用的类,用于连接到mvc操作. 谢谢

This is my class i'm using in order to connect to the mvc actions. Thank you

推荐答案

是的,它的工作并非来自服务器出现问题的afnetworking或mvc.对此感到抱歉

yes it worked it is not from the afnetworking or mvc the problem was with in the server. sorry for that

这篇关于阿拉伯数据显示?????使用afnetworking库将asp.net mvc中的字符转换为ios应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆