阿拉伯數據顯示?????從asp.net mvc到使用網絡庫處理響應對象的ios應用程序的字符。阿拉伯數據顯示?????從asp.net mvc到使用網絡庫的ios應用程序的字符
#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動作的類。 謝謝
則可能是web服務響應編碼問題,如果它不存在,那麼你必須對數據進行編碼,並顯示它,如果你從服務,您可以用阿拉伯語與[這個有用的類(HTTPS顯示它正確的數據://github.com/Accorpa/Arabic-Converter-From-and-To-Arabic-Presentation-Forms-B) – 2013-04-23 06:52:52
感謝你的幫助,它的工作,因爲我下面提到的,它是在服務器數據庫上的問題。 – HEH 2013-04-23 07:45:11
你能告訴我究竟是什麼問題,因爲我面臨着這個問題 – 2013-05-16 13:10:10