我正在使用AFNetworking來獲取JSON響應並根據它填充我的UITableView。但是,我在某些JSON響應中獲取了諸如<a href='link'>
之類的HTML標記。如何刪除它們並在填充我的tableview單元格時獲得正確的格式?使用AFNetworking從JSON響應解析HTML標記
下面是使用AFNetworking從JSON響應的tableview重新加載數據的代碼 -
NSURL *url = [NSURL URLWithString:@"http://xxxxx.com/api.php?req=all"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id responseObject) {
self.jobsArrayFromAFNetworking = [[responseObject objectForKey:@"all"]mutableCopy];
[spinner stopAnimating];
[self.tableView reloadData];
NSLog(@"JSON RESULT %@",responseObject);
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseObject){
NSLog(@"Request failed with error: %@, %@",error,error.userInfo);
}];
[operation start];
}
我不清楚:你想從數據中去掉HTML標籤,以便它們不會直接渲染到你的表格視圖單元格中嗎? – adpalumbo
我希望html標籤以正確的方式出現。間接地,我想從JSON響應到處解析這些html標籤。 –
所以你想呈現HTML標記,以便格式顯示在你的表格視圖單元格中? – adpalumbo