# HTML local files in swift

**URL:** <https://forums.kodeco.com/t/html-local-files-in-swift/16485>\
**Category:** Swift\
**Created:** [June 25, 2016, 3:44am UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485 "2016-06-25T03:44:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbrd](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@mbrd](https://forums.kodeco.com/u/mbrd)\
**Post date:** [June 25, 2016, 3:44am UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485/1 "2016-06-25T03:44:37Z")

</div>

Hello,  
I’m looking good practice to display local html files in webview of my detail view from a tableview.  
Each cell is linked to a specific html file.  
Can you help me ?

---

<div class="post-metadata">

**Author:** ![aeberbach](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aeberbach/32/81494_2.png) [@aeberbach](https://forums.kodeco.com/u/aeberbach)\
**Post date:** [June 27, 2016, 1:32am UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485/2 "2016-06-27T01:32:54Z")

</div>

Sure, you can do that - UIWebView has a function `loadHTMLString` that will be useful. Basically you want to store the local HTML in your app, load it as a string and pass it to UIWebView. NSFileManager will make things easy, and give you the ability to see if a file exists before you present it - this could be very useful if you use some kind of procedural name generation from your table view rather than hard-coding file names. For example you know you will have a series of 11 files, you simply name them 1 through 11.html and then load them by generating the filename with IndexPath.row.

---

<div class="post-metadata">

**Author:** ![mbrd](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@mbrd](https://forums.kodeco.com/u/mbrd)\
**Post date:** [June 27, 2016, 5:14am UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485/3 "2016-06-27T05:14:07Z")

</div>

Thank you,

Now I am reassured and i’ll can to continue working on my app following your valuable advice. I’ll look for good tutorials to learn.

Just to clarify, I can insert in my tableview (with links to my HTML files) a link to another tableview ?  
If this is not possible, I guess I can use the principle of two sections: one for the html files and one for the link to the tableview …

---

<div class="post-metadata">

**Author:** ![aeberbach](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aeberbach/32/81494_2.png) [@aeberbach](https://forums.kodeco.com/u/aeberbach)\
**Post date:** [July 11, 2016, 4:30am UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485/4 "2016-07-11T04:30:55Z")

</div>

So when you select a cell in your tableview you want to display another tableview? You would probably do performSegueWithIdentifier in the didSelectRowAtIndex method of the first tableview’s UITableViewDelegate object.

---

<div class="post-metadata">

**Author:** ![mbrd](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@mbrd](https://forums.kodeco.com/u/mbrd)\
**Post date:** [July 12, 2016, 2:53pm UTC](https://forums.kodeco.com/t/html-local-files-in-swift/16485/5 "2016-07-12T14:53:07Z")

</div>

Thank you for your reply.  
I found the solution that works correctly.
