I am currently using AFNetworking to consume a JSON web service from a Wordpress API.
This is the format that I am using:
[
{
id: 4,
title: "post1",
permalink: “http://www.example.com/test-post”,
content: “blah blah blah blah blah <iframe src="//player.vimeo.com/video/1010101?title=0&byline=0&portrait=0&color=ff5546" height="638" width="850" allowfullscreen="" frameborder="0"></iframe> more text blah blah <a href="http://example.com/wp-content/uploads/2014/01/testpic.png"><img class="aligncenter size-full wp-image-1180" alt="testpic" src="http://example.co/wp-content/uploads/2014/01/testpic.png" width="850" height="611" /></a>",
excerpt: " blah blah blah",
date: "2014-02-24 23:32:19",
author: "admin",
categories:
[
"Uncategorized"
],
tags: [ ]
},
{
id: 1,
title: "Hello world!",
permalink: “http://www.example.com/test-post”,
content: "Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!",
excerpt: "Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!",
date: "2014-02-24 22:48:12",
author: "admin",
categories:
[
"Uncategorized"
],
tags: [ ]
}
]
And I am consuming it as follows:
-(void)makeWordpressRequest
{
NSURL *URL = [NSURL URLWithString:@"http://example.com/feed/json"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
self.wordpress = responseObject;
[self.tableView reloadData];
NSLog(@"%@", responseObject);
} failure:nil];
[operation start];
}
Now here is my question.. I can successfully parse and display "content" string of the JSON, but I haven't figured out how to remove the "iframe" of the video and "a href" from that string to display it.
Is there anyway to embed them directly? Or could I split them from the JSON string programmatically and then embed them another way? I am currently using UITextView to display @"content".
Edit:
Not only remove the HTML but also a way to embed it correctly if possible..
Thank you for your help