开发者

Converting a HTML string to normal text using iphone dev

开发者 https://www.devze.com 2022-12-26 09:47 出处:网络
how to convert a HTML string to a plain text in iphone dev. Is there any in built functions which does it ?

how to convert a HTML string to a plain text in iphone dev. Is there any in built functions which does it ?

I am actually downloading a html string from web and showing it in the UIwebview and i am giving the user a edit option so that the html needs to converted to tet so that u开发者_如何学Pythonser can edit

Thanks...


It depends how you're downloading the HTML.

I would suggest that you use NSURLConnection and NSURLRequest to form a HTTP GET request and download the HTML that way.

You should implement the delegate methods for NSURLConneciton. You shoudl allocate an NSMutableData object to store the data you download, and append new data to it in -connection:didReceiveData:

Then once -connectionDidFinishLoading: is called, you can convert your NSData object into an NSString using

[[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];

This will give you the raw HTML of the page, which you can then push into a UIWebView, using loadHTMLString:baseURL: or pass into a UITextView with setText: for editing.

0

精彩评论

暂无评论...
验证码 换一张
取 消