阿拉伯数据显示 ????使用 afnetworking 库从 asp.net mvc 到 ios 应用程序的字符 [英] Arabic data is showing ????? characters from asp.net mvc to ios app using afnetworking library
本文介绍了阿拉伯数据显示 ????使用 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屋!
查看全文