Arabic data is showing ????? characters from asp.net mvc to ios app using afnetworking library [closed]

跟風遠走 提交于 2020-01-06 01:57:09

问题


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

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


回答1:


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



来源:https://stackoverflow.com/questions/16162494/arabic-data-is-showing-characters-from-asp-net-mvc-to-ios-app-using-afnetw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!