我有这段代码,我想使用编码来阅读阿拉伯语和表情符号。
使用 JSON
在 .h 我使用两个数组
NSArray *news;
NSMutableData *data;
在.m
在 viewDidLoad
NSURL *url = [NSURL URLWithString:@"http://myServer.com/getmessages.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
我已经使用了这些方法
-(void)connection: (NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
data = [[NSMutableData alloc]init];
}
-(void)connection: (NSURLConnection *)connection didReceiveData:(NSData *)theData
{
[data appendData:theData];
}
-(void)connectionDidFinishLoading: (NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
news = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];
if (news == nil || [news count] == 0) {
UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"Sorry!!" message:@" No News !!" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
[errorView show];
}
[self.tableView reloadData];
}
-(void)connection: (NSURLConnection *)connection didFailWithError:(NSError *)error
{
UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"Error" message:@"The download could not complete - Plaese make sure you're connected to either 3G or Wi-Fi" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
[errorView show];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
我使用 UITableView
cell.newsLabel.text = [[news objectAtIndex:indexPath.row]objectForKey:@"Content"];
阿拉伯语和表情符号的编码是什么?以及如何在此代码中使用编码