Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:32:05+00:00 2026-05-31T16:32:05+00:00

I am programming for iPhone, creating an app that shows various locally stored HTML

  • 0

I am programming for iPhone, creating an app that shows various locally stored HTML pages in a UIWebView. All of the pages are identical in structure and styling, with the only difference being their content.

Right now I have it programmed with a “Master View” (UITableView) and when the user selects a cell the overall Navigation Controller pushes a “Detail View” onto the stack, which contains a UIWebView. When the Detail View will be shown, its WebView HTML content is loaded in.

Since all pages are identical structurally, I thought it would be simpler to set up an HTML template page and load in the text. From my understanding, this is how PHP works. User loads up an Amazon page for an item, every one of them has identical structure and styling but the PHP code pulls in the title, description, etc. for that specific item.

I want to know the best way to do this on an iPhone with a UIWebView. Since I am not a web wizard and am unfamiliar with Javascript, let alone PHP, my thought was this:

Load the HTML template from a local file into an NSString object. The template contains tags with special IDs to indicate where pieces of text go. Use NSString find & replace methods to locate each special tag and insert the appropriate pieces of text.

That will be simple to program and I believe it will be pretty efficient too, especially since I’m only doing 4-5 replacements when I load the page. If anybody has a better suggestion (especially a thorough suggestion) I wouldn’t mind hearing it.

Now, that’s not really my problem. I’m more wondering what is the best way to store and retrieve the multi-line HTML strings that will be inserted into the template. As far as I know, on normal web pages, PHP retrieves pieces of an XML file, or queries against a SQL database.

The two data storage/retrieval methods I am familiar with on iPhone are Plist files and Strings files. Strings files seem fairly convenient to me, since they can store multiline strings, except that I would have to escape every double-quote anywhere in the string (and there are some, since it is HTML) and that Strings files seem to be specifically designed by Apple for internationalization, not dynamic web pages.

As for Plist files, you can easily have an array of Strings, but it is not multiline-friendly. The Plist editor in the latest XCode only shows one line at a time, making it a bit annoying to work with, and once again making me feel like I’m going against Apple’s intended use for a Plist by filling it with huge strings. Secondly, the only ways I can find to read data out of a Plist is to load the entire thing into an NSData or serialize it into objects and whatnot. I feel like it would be silly to re-serialize the Plist every time I need to reconfigure my UIWebView, and wasteful of memory to serialize the Plist and keep the resultant objects in memory the entire time my App is going. I suppose it can’t take up that much memory since it’s just text, but I’m not really sure.

It may be that, instead of altering the HTML before it is delivered to the WebView, I should have template Javascript in the HTML that pulls the strings from a local XML file (and the Objective-C simply parses key strings into the JS before giving the HTML to the WebView) so that the WebView’s JS logic does the actual replacements. However, I don’t really know how to do this and the AJAX tutorials I found always referred to external servers, script libraries that I wasn’t sure how to use with a UIWebView, etc.

In closing, I would be thankful for any advice on how to carry this out. Whatever your suggestion, the more detailed it is the better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:32:06+00:00Added an answer on May 31, 2026 at 4:32 pm

    As far as I know, on normal web pages, PHP retrieves pieces of an XML file, or queries against a SQL database

    No. Well, yes, it might. But PHP can output anything. Pretty much like Objective-C.

    The two data storage/retrieval methods I am familiar with on iPhone are Plist files and Strings files.

    Those are just special formats propagated by Apple. You can use any file format you want. Use stringWithContentsOfFile

    I feel like it would be silly to re-serialize the Plist every time I need to reconfigure my UIWebView, and wasteful of memory to serialize the Plist and keep the resultant objects in memory the entire time my App is going.

    You don’t have much of a choice. An alternative approach: Use disk caching. Save the rendered template as a file when it is first accessed. Next time check for existence of a cached file.

    It may be that, instead of altering the HTML before it is delivered to the WebView, I should have … the WebView’s JS logic does the actual replacements.

    That’s probably a bad idea. JS is much slower and more memory hungry than Obj-C. Besides, there’s nothing that JS can do and Obj-C can’t.

    If you’re not worried about the inevitable overhead you may consider using a fully-featured templating engine

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've followed all posts that I've found about creating a Universal App that uses
A friend and I are creating an iPhone app together. He's programming the user
My fellow developer and I are creating an iPhone app that is creating a
I am programming an iPhone app, and I need to force it to exit
I'm programming an iPhone app and I'm wondering how programmers properly position controls without
I am new to iphone programming. I heard from few people that even if
im new to iPhone programming..in my app the timer is not working fine. can
I'm fairly new to iPhone programming, and I'm making a fairly basic app. Anyway,
I've just recently started programming for the iPhone and I'm making an application that
From the iPhone Programming Guide When creating files or writing out file data, keep

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.